Why are IP addresses given to each interface and not device? What would the implications of that be?
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Thanks,
routing ip network internet ip-address
New contributor
add a comment |
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Thanks,
routing ip network internet ip-address
New contributor
1
Some devices do only get an IP for management that it isn't tied to any particular interface. Others work in the way you described. It varies by device, model, and software/firmware. In addition, you may need to assign different IP address per interface depending on a task's requirements.
– Jesse P.
16 hours ago
1
Short answer - to make routers possible. A router is just a computer (these days most likely Linux) that needs to connect to different networks - thus must have the ability to have multiple IP addresses. The multiple IP per device thing came about at roughly the same time as the invention of the router.
– slebetman
12 hours ago
add a comment |
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Thanks,
routing ip network internet ip-address
New contributor
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Thanks,
routing ip network internet ip-address
routing ip network internet ip-address
New contributor
New contributor
New contributor
asked 16 hours ago
Tiago OliveiraTiago Oliveira
462
462
New contributor
New contributor
1
Some devices do only get an IP for management that it isn't tied to any particular interface. Others work in the way you described. It varies by device, model, and software/firmware. In addition, you may need to assign different IP address per interface depending on a task's requirements.
– Jesse P.
16 hours ago
1
Short answer - to make routers possible. A router is just a computer (these days most likely Linux) that needs to connect to different networks - thus must have the ability to have multiple IP addresses. The multiple IP per device thing came about at roughly the same time as the invention of the router.
– slebetman
12 hours ago
add a comment |
1
Some devices do only get an IP for management that it isn't tied to any particular interface. Others work in the way you described. It varies by device, model, and software/firmware. In addition, you may need to assign different IP address per interface depending on a task's requirements.
– Jesse P.
16 hours ago
1
Short answer - to make routers possible. A router is just a computer (these days most likely Linux) that needs to connect to different networks - thus must have the ability to have multiple IP addresses. The multiple IP per device thing came about at roughly the same time as the invention of the router.
– slebetman
12 hours ago
1
1
Some devices do only get an IP for management that it isn't tied to any particular interface. Others work in the way you described. It varies by device, model, and software/firmware. In addition, you may need to assign different IP address per interface depending on a task's requirements.
– Jesse P.
16 hours ago
Some devices do only get an IP for management that it isn't tied to any particular interface. Others work in the way you described. It varies by device, model, and software/firmware. In addition, you may need to assign different IP address per interface depending on a task's requirements.
– Jesse P.
16 hours ago
1
1
Short answer - to make routers possible. A router is just a computer (these days most likely Linux) that needs to connect to different networks - thus must have the ability to have multiple IP addresses. The multiple IP per device thing came about at roughly the same time as the invention of the router.
– slebetman
12 hours ago
Short answer - to make routers possible. A router is just a computer (these days most likely Linux) that needs to connect to different networks - thus must have the ability to have multiple IP addresses. The multiple IP per device thing came about at roughly the same time as the invention of the router.
– slebetman
12 hours ago
add a comment |
7 Answers
7
active
oldest
votes
Connecting an interface to a network makes it a part of that network. Therefore, the IP address is a property of the connection, not the host.
Likewise, a host can have many network connections and accordingly, IP addresses.
Routers require multiple IP addresses for their interfaces.
add a comment |
No.
That said, let's see a simplified example:
I have a computer with three interfaces: eth0
(wired Ethernet), wlan0
(wifi), and vboxnet0
(virtualbox). One of the interfaces is connected to an internal network, one is connected to the internet, and the last one is connected to a network of virtual computers. Let's say I have just one address, 10.1.2.3, and wish to send a whole lot of packets to 192.168.1.2, reachable on one of those networks - where do I send them to? Can't just send them Everywhere, such behavior would flood all the networks in short order.
But if the eth0 interface has 192.168.1.3, wlan0 has 10.1.2.3, and vboxnet0 has 172.0.0.1, then the default routing table will probably say "send it out eth0". (This can obviously get far more complicated with more complex routing rules).
And conversely, I may wish to run a service only on the interface that's open to the private network - so when a request comes in on a different interface, it's not handled at all.
New contributor
1
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
add a comment |
Case 1: Routers
Theoretically this would be possible.
However, normally an IP packet is sent "directly" to the destination when the IP address "matches" a certain network mask (e.g. 10.0.0.0/28); otherwise the packet is sent over a router.
This means:
- A router connects two networks; each of the two networks has a network mask
Packets being sent from one computer to another within one of the two networks do not pass a router.
This means that the IP addresses of each computer match the network mask of the network they are connected to.
Packets being sent to the router (this includes packets being routed by the router!) are not sent from a computer to the router via a second router.
This means that the IP address of the router must match the network masks of both networks.
IP packets being sent from one computer in one network to a computer in the other network however are sent over the router.
This means that the IP addresses of the computers in one network must not match the network mask of the other network.
It is nearly impossible to choose an IP address and two network masks in a way that one IP address matches both network masks but a lot of IP addresses only match one network mask.
Case 2: Different private networks
We could have the case that a computer is connected to two private networks which cannot exchange data between each other.
In this case a computer may have the same IP address in both networks.
In the case of IPv4 most OSs won't support this because the OSs use the network masks of the two networks to distinguish between them. The networks need to have different network masks...
In the case of IPv6 (using "link-local" addresses) a computer can have the same (link-local) IP address in two different networks - and therefore two network cards can have the same IP address!
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
add a comment |
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Let me start by challenging your assumption. Why do you say this isn't how machines behave? Say I assign 192.168.1.1/24 to eth1 and 192.168.2.1/24 to eth2. Other than installing a route for 192.168.1.0/24 out eth1 and 192.168.2.0/24 out eth2 and determining the preferred source IP address for packets sent along that route, how much does it really matter which interface I assign the IP address to? What really changes? In what sense does the machine not behave as if all IP addresses assigned to interfaces on the machine belong to the machine?
Both approaches are used. The most common approach is actually a hybrid of these two approaches.
On the "give a device an IP address" extreme, you could imagine a device that behaved as if all of its interfaces were connected to a filtering bridge with one IP address assigned to the bridge.
On the "give each interface an IP address" extreme, you could imagine a device that behaved as if each interface it had was like a separate machine. (See here if you think that's how devices currently work or think about someone who connects to an IP address assigned to one interface but the packets arrive on and are sent out another one.)
In practice, most machines operate somewhere in-between. They do act as if all IP addresses were owned by the machine. The assignment of an IP to a particular device doesn't really do all that much beyond telling the OS to install a default route out that interface and to set the default source IP address for packets sent out that interface where the source IP address isn't forced.
Otherwise, they do behave as if all IP addresses belonged to the machine. The way a packet is processed doesn't depend much on what interface it is received on -- packets with a source IP address assigned to one interface received on another are routine. Which interface an address is assigned to has no direct effect on which interface a packet is sent out, the routing table determines that.
add a comment |
In the general case, you do need one IP per local network you connect it, and this is just how TCP/IP was defined: each host on a given local network has an IP address, which allows:
- to route traffic to the appropriate local network, based on the destination IP address
- to direct traffic to the appopriate device on that local network (after an ARP lookup on 802.x local networks, for instance).
As long as you have local networks with multiple devices connected to it (most 802.x local networks, including Ethernet, Wi-Fi), it's quite difficult to go around that unless you fundamentally change the way TCP/IP works.
However, it is actually possible to avoid that, though it is quite specific.
Consider a network that only has point-to-point links (point-to-point Ethernet between two devices without a switch or hub, DSL links, SONET/SDH links, Frame Relay or ATM VCs...).
The usual convention is to use a /30 for each link, so the device at each end has an IP address on that link.
But you can use "IP unnumbered", and not associate any IP addresses to those links. Now, you assign an IP to the device's loopback interface (any interface really, but loopback is the easiest one for this purpose), and you use a dynamic routing protocol (IS-IS, OSPF, EIGRP...). This routing protocol will advertise how to route traffic to that IP address via the various unnumbered links.
add a comment |
A device that has an IP address exists within a network.
A Router is a device who's primary purpose is to pass traffic between networks.
For a Router to pass packets between two networks, it must exist within both networks.
The Router will have an "arm" inside each network -- or as we call it, an interface. And the way an interface exists within a network is by assigning it an IP address within the network.
Hence, when configuring a router, each interface receives an IP address to identify the networks which that Router belongs within.
Disclaimer: The link above is to my blog. My blog is not monetized. I make no profit from you reading it. I am providing a link simply for your (and any other reader's) benefit.
1
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
add a comment |
IP addresses include routing information. An IP address is split up into two components, the network number and the host number, based on an assigned prefix length (which was originally expressed as a network mask, and this is still often how it's implemented internally in network stacks).
For routing to work properly, all the devices connected to a particular network must have addresses with the same network number. Senders determine whether the receiver is on the same or a different network by comparing their own network number with the receiver's address. If they're in the same network, they send directly; otherwise, they send to a router whose job is to get the message closer to the destination.
So if a device is connected to multiple networks, it needs an address on each of those networks so it can be reached by devices on that network.
That said, it isn't really necessary for the addresses to be assigned specifically to particular network interfaces. The device could just have a list of all the IPs that it owns in a single table. But the interfaces still need information about which network they're connected to. By assigning an IP and network mask to each interface we put this information in one place, simplifying the design. There's no need for extra code to keep the list of IPs consistent with the list of networks that interfaces are connected to.
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "496"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Tiago Oliveira is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fnetworkengineering.stackexchange.com%2fquestions%2f56156%2fwhy-are-ip-addresses-given-to-each-interface-and-not-device-what-would-the-impl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
Connecting an interface to a network makes it a part of that network. Therefore, the IP address is a property of the connection, not the host.
Likewise, a host can have many network connections and accordingly, IP addresses.
Routers require multiple IP addresses for their interfaces.
add a comment |
Connecting an interface to a network makes it a part of that network. Therefore, the IP address is a property of the connection, not the host.
Likewise, a host can have many network connections and accordingly, IP addresses.
Routers require multiple IP addresses for their interfaces.
add a comment |
Connecting an interface to a network makes it a part of that network. Therefore, the IP address is a property of the connection, not the host.
Likewise, a host can have many network connections and accordingly, IP addresses.
Routers require multiple IP addresses for their interfaces.
Connecting an interface to a network makes it a part of that network. Therefore, the IP address is a property of the connection, not the host.
Likewise, a host can have many network connections and accordingly, IP addresses.
Routers require multiple IP addresses for their interfaces.
edited 12 hours ago
answered 15 hours ago
Zac67Zac67
27.3k21355
27.3k21355
add a comment |
add a comment |
No.
That said, let's see a simplified example:
I have a computer with three interfaces: eth0
(wired Ethernet), wlan0
(wifi), and vboxnet0
(virtualbox). One of the interfaces is connected to an internal network, one is connected to the internet, and the last one is connected to a network of virtual computers. Let's say I have just one address, 10.1.2.3, and wish to send a whole lot of packets to 192.168.1.2, reachable on one of those networks - where do I send them to? Can't just send them Everywhere, such behavior would flood all the networks in short order.
But if the eth0 interface has 192.168.1.3, wlan0 has 10.1.2.3, and vboxnet0 has 172.0.0.1, then the default routing table will probably say "send it out eth0". (This can obviously get far more complicated with more complex routing rules).
And conversely, I may wish to run a service only on the interface that's open to the private network - so when a request comes in on a different interface, it's not handled at all.
New contributor
1
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
add a comment |
No.
That said, let's see a simplified example:
I have a computer with three interfaces: eth0
(wired Ethernet), wlan0
(wifi), and vboxnet0
(virtualbox). One of the interfaces is connected to an internal network, one is connected to the internet, and the last one is connected to a network of virtual computers. Let's say I have just one address, 10.1.2.3, and wish to send a whole lot of packets to 192.168.1.2, reachable on one of those networks - where do I send them to? Can't just send them Everywhere, such behavior would flood all the networks in short order.
But if the eth0 interface has 192.168.1.3, wlan0 has 10.1.2.3, and vboxnet0 has 172.0.0.1, then the default routing table will probably say "send it out eth0". (This can obviously get far more complicated with more complex routing rules).
And conversely, I may wish to run a service only on the interface that's open to the private network - so when a request comes in on a different interface, it's not handled at all.
New contributor
1
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
add a comment |
No.
That said, let's see a simplified example:
I have a computer with three interfaces: eth0
(wired Ethernet), wlan0
(wifi), and vboxnet0
(virtualbox). One of the interfaces is connected to an internal network, one is connected to the internet, and the last one is connected to a network of virtual computers. Let's say I have just one address, 10.1.2.3, and wish to send a whole lot of packets to 192.168.1.2, reachable on one of those networks - where do I send them to? Can't just send them Everywhere, such behavior would flood all the networks in short order.
But if the eth0 interface has 192.168.1.3, wlan0 has 10.1.2.3, and vboxnet0 has 172.0.0.1, then the default routing table will probably say "send it out eth0". (This can obviously get far more complicated with more complex routing rules).
And conversely, I may wish to run a service only on the interface that's open to the private network - so when a request comes in on a different interface, it's not handled at all.
New contributor
No.
That said, let's see a simplified example:
I have a computer with three interfaces: eth0
(wired Ethernet), wlan0
(wifi), and vboxnet0
(virtualbox). One of the interfaces is connected to an internal network, one is connected to the internet, and the last one is connected to a network of virtual computers. Let's say I have just one address, 10.1.2.3, and wish to send a whole lot of packets to 192.168.1.2, reachable on one of those networks - where do I send them to? Can't just send them Everywhere, such behavior would flood all the networks in short order.
But if the eth0 interface has 192.168.1.3, wlan0 has 10.1.2.3, and vboxnet0 has 172.0.0.1, then the default routing table will probably say "send it out eth0". (This can obviously get far more complicated with more complex routing rules).
And conversely, I may wish to run a service only on the interface that's open to the private network - so when a request comes in on a different interface, it's not handled at all.
New contributor
New contributor
answered 13 hours ago
PiskvorPiskvor
1913
1913
New contributor
New contributor
1
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
add a comment |
1
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
1
1
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
Why couldn't you know what is reachable at each interface without those having different IP addresses?
– Paŭlo Ebermann
6 hours ago
add a comment |
Case 1: Routers
Theoretically this would be possible.
However, normally an IP packet is sent "directly" to the destination when the IP address "matches" a certain network mask (e.g. 10.0.0.0/28); otherwise the packet is sent over a router.
This means:
- A router connects two networks; each of the two networks has a network mask
Packets being sent from one computer to another within one of the two networks do not pass a router.
This means that the IP addresses of each computer match the network mask of the network they are connected to.
Packets being sent to the router (this includes packets being routed by the router!) are not sent from a computer to the router via a second router.
This means that the IP address of the router must match the network masks of both networks.
IP packets being sent from one computer in one network to a computer in the other network however are sent over the router.
This means that the IP addresses of the computers in one network must not match the network mask of the other network.
It is nearly impossible to choose an IP address and two network masks in a way that one IP address matches both network masks but a lot of IP addresses only match one network mask.
Case 2: Different private networks
We could have the case that a computer is connected to two private networks which cannot exchange data between each other.
In this case a computer may have the same IP address in both networks.
In the case of IPv4 most OSs won't support this because the OSs use the network masks of the two networks to distinguish between them. The networks need to have different network masks...
In the case of IPv6 (using "link-local" addresses) a computer can have the same (link-local) IP address in two different networks - and therefore two network cards can have the same IP address!
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
add a comment |
Case 1: Routers
Theoretically this would be possible.
However, normally an IP packet is sent "directly" to the destination when the IP address "matches" a certain network mask (e.g. 10.0.0.0/28); otherwise the packet is sent over a router.
This means:
- A router connects two networks; each of the two networks has a network mask
Packets being sent from one computer to another within one of the two networks do not pass a router.
This means that the IP addresses of each computer match the network mask of the network they are connected to.
Packets being sent to the router (this includes packets being routed by the router!) are not sent from a computer to the router via a second router.
This means that the IP address of the router must match the network masks of both networks.
IP packets being sent from one computer in one network to a computer in the other network however are sent over the router.
This means that the IP addresses of the computers in one network must not match the network mask of the other network.
It is nearly impossible to choose an IP address and two network masks in a way that one IP address matches both network masks but a lot of IP addresses only match one network mask.
Case 2: Different private networks
We could have the case that a computer is connected to two private networks which cannot exchange data between each other.
In this case a computer may have the same IP address in both networks.
In the case of IPv4 most OSs won't support this because the OSs use the network masks of the two networks to distinguish between them. The networks need to have different network masks...
In the case of IPv6 (using "link-local" addresses) a computer can have the same (link-local) IP address in two different networks - and therefore two network cards can have the same IP address!
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
add a comment |
Case 1: Routers
Theoretically this would be possible.
However, normally an IP packet is sent "directly" to the destination when the IP address "matches" a certain network mask (e.g. 10.0.0.0/28); otherwise the packet is sent over a router.
This means:
- A router connects two networks; each of the two networks has a network mask
Packets being sent from one computer to another within one of the two networks do not pass a router.
This means that the IP addresses of each computer match the network mask of the network they are connected to.
Packets being sent to the router (this includes packets being routed by the router!) are not sent from a computer to the router via a second router.
This means that the IP address of the router must match the network masks of both networks.
IP packets being sent from one computer in one network to a computer in the other network however are sent over the router.
This means that the IP addresses of the computers in one network must not match the network mask of the other network.
It is nearly impossible to choose an IP address and two network masks in a way that one IP address matches both network masks but a lot of IP addresses only match one network mask.
Case 2: Different private networks
We could have the case that a computer is connected to two private networks which cannot exchange data between each other.
In this case a computer may have the same IP address in both networks.
In the case of IPv4 most OSs won't support this because the OSs use the network masks of the two networks to distinguish between them. The networks need to have different network masks...
In the case of IPv6 (using "link-local" addresses) a computer can have the same (link-local) IP address in two different networks - and therefore two network cards can have the same IP address!
Case 1: Routers
Theoretically this would be possible.
However, normally an IP packet is sent "directly" to the destination when the IP address "matches" a certain network mask (e.g. 10.0.0.0/28); otherwise the packet is sent over a router.
This means:
- A router connects two networks; each of the two networks has a network mask
Packets being sent from one computer to another within one of the two networks do not pass a router.
This means that the IP addresses of each computer match the network mask of the network they are connected to.
Packets being sent to the router (this includes packets being routed by the router!) are not sent from a computer to the router via a second router.
This means that the IP address of the router must match the network masks of both networks.
IP packets being sent from one computer in one network to a computer in the other network however are sent over the router.
This means that the IP addresses of the computers in one network must not match the network mask of the other network.
It is nearly impossible to choose an IP address and two network masks in a way that one IP address matches both network masks but a lot of IP addresses only match one network mask.
Case 2: Different private networks
We could have the case that a computer is connected to two private networks which cannot exchange data between each other.
In this case a computer may have the same IP address in both networks.
In the case of IPv4 most OSs won't support this because the OSs use the network masks of the two networks to distinguish between them. The networks need to have different network masks...
In the case of IPv6 (using "link-local" addresses) a computer can have the same (link-local) IP address in two different networks - and therefore two network cards can have the same IP address!
answered 13 hours ago
Martin RosenauMartin Rosenau
9157
9157
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
add a comment |
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
In one specific case, TSN specifications for ethernet do allow multiple interfaces with the same IP, mask, and MAC Address in order to support seamless redundant paths for deterministic ethernet (802.1cb). The redundancy is handled at the MAC level (detection of duplicate packed and ignoring redundant information) so from the hosts perspective it is one interface.
– crasic
8 hours ago
add a comment |
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Let me start by challenging your assumption. Why do you say this isn't how machines behave? Say I assign 192.168.1.1/24 to eth1 and 192.168.2.1/24 to eth2. Other than installing a route for 192.168.1.0/24 out eth1 and 192.168.2.0/24 out eth2 and determining the preferred source IP address for packets sent along that route, how much does it really matter which interface I assign the IP address to? What really changes? In what sense does the machine not behave as if all IP addresses assigned to interfaces on the machine belong to the machine?
Both approaches are used. The most common approach is actually a hybrid of these two approaches.
On the "give a device an IP address" extreme, you could imagine a device that behaved as if all of its interfaces were connected to a filtering bridge with one IP address assigned to the bridge.
On the "give each interface an IP address" extreme, you could imagine a device that behaved as if each interface it had was like a separate machine. (See here if you think that's how devices currently work or think about someone who connects to an IP address assigned to one interface but the packets arrive on and are sent out another one.)
In practice, most machines operate somewhere in-between. They do act as if all IP addresses were owned by the machine. The assignment of an IP to a particular device doesn't really do all that much beyond telling the OS to install a default route out that interface and to set the default source IP address for packets sent out that interface where the source IP address isn't forced.
Otherwise, they do behave as if all IP addresses belonged to the machine. The way a packet is processed doesn't depend much on what interface it is received on -- packets with a source IP address assigned to one interface received on another are routine. Which interface an address is assigned to has no direct effect on which interface a packet is sent out, the routing table determines that.
add a comment |
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Let me start by challenging your assumption. Why do you say this isn't how machines behave? Say I assign 192.168.1.1/24 to eth1 and 192.168.2.1/24 to eth2. Other than installing a route for 192.168.1.0/24 out eth1 and 192.168.2.0/24 out eth2 and determining the preferred source IP address for packets sent along that route, how much does it really matter which interface I assign the IP address to? What really changes? In what sense does the machine not behave as if all IP addresses assigned to interfaces on the machine belong to the machine?
Both approaches are used. The most common approach is actually a hybrid of these two approaches.
On the "give a device an IP address" extreme, you could imagine a device that behaved as if all of its interfaces were connected to a filtering bridge with one IP address assigned to the bridge.
On the "give each interface an IP address" extreme, you could imagine a device that behaved as if each interface it had was like a separate machine. (See here if you think that's how devices currently work or think about someone who connects to an IP address assigned to one interface but the packets arrive on and are sent out another one.)
In practice, most machines operate somewhere in-between. They do act as if all IP addresses were owned by the machine. The assignment of an IP to a particular device doesn't really do all that much beyond telling the OS to install a default route out that interface and to set the default source IP address for packets sent out that interface where the source IP address isn't forced.
Otherwise, they do behave as if all IP addresses belonged to the machine. The way a packet is processed doesn't depend much on what interface it is received on -- packets with a source IP address assigned to one interface received on another are routine. Which interface an address is assigned to has no direct effect on which interface a packet is sent out, the routing table determines that.
add a comment |
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Let me start by challenging your assumption. Why do you say this isn't how machines behave? Say I assign 192.168.1.1/24 to eth1 and 192.168.2.1/24 to eth2. Other than installing a route for 192.168.1.0/24 out eth1 and 192.168.2.0/24 out eth2 and determining the preferred source IP address for packets sent along that route, how much does it really matter which interface I assign the IP address to? What really changes? In what sense does the machine not behave as if all IP addresses assigned to interfaces on the machine belong to the machine?
Both approaches are used. The most common approach is actually a hybrid of these two approaches.
On the "give a device an IP address" extreme, you could imagine a device that behaved as if all of its interfaces were connected to a filtering bridge with one IP address assigned to the bridge.
On the "give each interface an IP address" extreme, you could imagine a device that behaved as if each interface it had was like a separate machine. (See here if you think that's how devices currently work or think about someone who connects to an IP address assigned to one interface but the packets arrive on and are sent out another one.)
In practice, most machines operate somewhere in-between. They do act as if all IP addresses were owned by the machine. The assignment of an IP to a particular device doesn't really do all that much beyond telling the OS to install a default route out that interface and to set the default source IP address for packets sent out that interface where the source IP address isn't forced.
Otherwise, they do behave as if all IP addresses belonged to the machine. The way a packet is processed doesn't depend much on what interface it is received on -- packets with a source IP address assigned to one interface received on another are routine. Which interface an address is assigned to has no direct effect on which interface a packet is sent out, the routing table determines that.
I was wondering, why do we need to give IP addresses to each interface? Wouldn't giving to each device enough?
Let me start by challenging your assumption. Why do you say this isn't how machines behave? Say I assign 192.168.1.1/24 to eth1 and 192.168.2.1/24 to eth2. Other than installing a route for 192.168.1.0/24 out eth1 and 192.168.2.0/24 out eth2 and determining the preferred source IP address for packets sent along that route, how much does it really matter which interface I assign the IP address to? What really changes? In what sense does the machine not behave as if all IP addresses assigned to interfaces on the machine belong to the machine?
Both approaches are used. The most common approach is actually a hybrid of these two approaches.
On the "give a device an IP address" extreme, you could imagine a device that behaved as if all of its interfaces were connected to a filtering bridge with one IP address assigned to the bridge.
On the "give each interface an IP address" extreme, you could imagine a device that behaved as if each interface it had was like a separate machine. (See here if you think that's how devices currently work or think about someone who connects to an IP address assigned to one interface but the packets arrive on and are sent out another one.)
In practice, most machines operate somewhere in-between. They do act as if all IP addresses were owned by the machine. The assignment of an IP to a particular device doesn't really do all that much beyond telling the OS to install a default route out that interface and to set the default source IP address for packets sent out that interface where the source IP address isn't forced.
Otherwise, they do behave as if all IP addresses belonged to the machine. The way a packet is processed doesn't depend much on what interface it is received on -- packets with a source IP address assigned to one interface received on another are routine. Which interface an address is assigned to has no direct effect on which interface a packet is sent out, the routing table determines that.
edited 10 hours ago
answered 11 hours ago
David SchwartzDavid Schwartz
23116
23116
add a comment |
add a comment |
In the general case, you do need one IP per local network you connect it, and this is just how TCP/IP was defined: each host on a given local network has an IP address, which allows:
- to route traffic to the appropriate local network, based on the destination IP address
- to direct traffic to the appopriate device on that local network (after an ARP lookup on 802.x local networks, for instance).
As long as you have local networks with multiple devices connected to it (most 802.x local networks, including Ethernet, Wi-Fi), it's quite difficult to go around that unless you fundamentally change the way TCP/IP works.
However, it is actually possible to avoid that, though it is quite specific.
Consider a network that only has point-to-point links (point-to-point Ethernet between two devices without a switch or hub, DSL links, SONET/SDH links, Frame Relay or ATM VCs...).
The usual convention is to use a /30 for each link, so the device at each end has an IP address on that link.
But you can use "IP unnumbered", and not associate any IP addresses to those links. Now, you assign an IP to the device's loopback interface (any interface really, but loopback is the easiest one for this purpose), and you use a dynamic routing protocol (IS-IS, OSPF, EIGRP...). This routing protocol will advertise how to route traffic to that IP address via the various unnumbered links.
add a comment |
In the general case, you do need one IP per local network you connect it, and this is just how TCP/IP was defined: each host on a given local network has an IP address, which allows:
- to route traffic to the appropriate local network, based on the destination IP address
- to direct traffic to the appopriate device on that local network (after an ARP lookup on 802.x local networks, for instance).
As long as you have local networks with multiple devices connected to it (most 802.x local networks, including Ethernet, Wi-Fi), it's quite difficult to go around that unless you fundamentally change the way TCP/IP works.
However, it is actually possible to avoid that, though it is quite specific.
Consider a network that only has point-to-point links (point-to-point Ethernet between two devices without a switch or hub, DSL links, SONET/SDH links, Frame Relay or ATM VCs...).
The usual convention is to use a /30 for each link, so the device at each end has an IP address on that link.
But you can use "IP unnumbered", and not associate any IP addresses to those links. Now, you assign an IP to the device's loopback interface (any interface really, but loopback is the easiest one for this purpose), and you use a dynamic routing protocol (IS-IS, OSPF, EIGRP...). This routing protocol will advertise how to route traffic to that IP address via the various unnumbered links.
add a comment |
In the general case, you do need one IP per local network you connect it, and this is just how TCP/IP was defined: each host on a given local network has an IP address, which allows:
- to route traffic to the appropriate local network, based on the destination IP address
- to direct traffic to the appopriate device on that local network (after an ARP lookup on 802.x local networks, for instance).
As long as you have local networks with multiple devices connected to it (most 802.x local networks, including Ethernet, Wi-Fi), it's quite difficult to go around that unless you fundamentally change the way TCP/IP works.
However, it is actually possible to avoid that, though it is quite specific.
Consider a network that only has point-to-point links (point-to-point Ethernet between two devices without a switch or hub, DSL links, SONET/SDH links, Frame Relay or ATM VCs...).
The usual convention is to use a /30 for each link, so the device at each end has an IP address on that link.
But you can use "IP unnumbered", and not associate any IP addresses to those links. Now, you assign an IP to the device's loopback interface (any interface really, but loopback is the easiest one for this purpose), and you use a dynamic routing protocol (IS-IS, OSPF, EIGRP...). This routing protocol will advertise how to route traffic to that IP address via the various unnumbered links.
In the general case, you do need one IP per local network you connect it, and this is just how TCP/IP was defined: each host on a given local network has an IP address, which allows:
- to route traffic to the appropriate local network, based on the destination IP address
- to direct traffic to the appopriate device on that local network (after an ARP lookup on 802.x local networks, for instance).
As long as you have local networks with multiple devices connected to it (most 802.x local networks, including Ethernet, Wi-Fi), it's quite difficult to go around that unless you fundamentally change the way TCP/IP works.
However, it is actually possible to avoid that, though it is quite specific.
Consider a network that only has point-to-point links (point-to-point Ethernet between two devices without a switch or hub, DSL links, SONET/SDH links, Frame Relay or ATM VCs...).
The usual convention is to use a /30 for each link, so the device at each end has an IP address on that link.
But you can use "IP unnumbered", and not associate any IP addresses to those links. Now, you assign an IP to the device's loopback interface (any interface really, but loopback is the easiest one for this purpose), and you use a dynamic routing protocol (IS-IS, OSPF, EIGRP...). This routing protocol will advertise how to route traffic to that IP address via the various unnumbered links.
answered 12 hours ago
jcaronjcaron
39119
39119
add a comment |
add a comment |
A device that has an IP address exists within a network.
A Router is a device who's primary purpose is to pass traffic between networks.
For a Router to pass packets between two networks, it must exist within both networks.
The Router will have an "arm" inside each network -- or as we call it, an interface. And the way an interface exists within a network is by assigning it an IP address within the network.
Hence, when configuring a router, each interface receives an IP address to identify the networks which that Router belongs within.
Disclaimer: The link above is to my blog. My blog is not monetized. I make no profit from you reading it. I am providing a link simply for your (and any other reader's) benefit.
1
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
add a comment |
A device that has an IP address exists within a network.
A Router is a device who's primary purpose is to pass traffic between networks.
For a Router to pass packets between two networks, it must exist within both networks.
The Router will have an "arm" inside each network -- or as we call it, an interface. And the way an interface exists within a network is by assigning it an IP address within the network.
Hence, when configuring a router, each interface receives an IP address to identify the networks which that Router belongs within.
Disclaimer: The link above is to my blog. My blog is not monetized. I make no profit from you reading it. I am providing a link simply for your (and any other reader's) benefit.
1
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
add a comment |
A device that has an IP address exists within a network.
A Router is a device who's primary purpose is to pass traffic between networks.
For a Router to pass packets between two networks, it must exist within both networks.
The Router will have an "arm" inside each network -- or as we call it, an interface. And the way an interface exists within a network is by assigning it an IP address within the network.
Hence, when configuring a router, each interface receives an IP address to identify the networks which that Router belongs within.
Disclaimer: The link above is to my blog. My blog is not monetized. I make no profit from you reading it. I am providing a link simply for your (and any other reader's) benefit.
A device that has an IP address exists within a network.
A Router is a device who's primary purpose is to pass traffic between networks.
For a Router to pass packets between two networks, it must exist within both networks.
The Router will have an "arm" inside each network -- or as we call it, an interface. And the way an interface exists within a network is by assigning it an IP address within the network.
Hence, when configuring a router, each interface receives an IP address to identify the networks which that Router belongs within.
Disclaimer: The link above is to my blog. My blog is not monetized. I make no profit from you reading it. I am providing a link simply for your (and any other reader's) benefit.
edited 7 hours ago
answered 14 hours ago
EddieEddie
9,12822358
9,12822358
1
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
add a comment |
1
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
1
1
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
Nice and concise answer, very clear way of explaining why.
– Stilez
10 hours ago
add a comment |
IP addresses include routing information. An IP address is split up into two components, the network number and the host number, based on an assigned prefix length (which was originally expressed as a network mask, and this is still often how it's implemented internally in network stacks).
For routing to work properly, all the devices connected to a particular network must have addresses with the same network number. Senders determine whether the receiver is on the same or a different network by comparing their own network number with the receiver's address. If they're in the same network, they send directly; otherwise, they send to a router whose job is to get the message closer to the destination.
So if a device is connected to multiple networks, it needs an address on each of those networks so it can be reached by devices on that network.
That said, it isn't really necessary for the addresses to be assigned specifically to particular network interfaces. The device could just have a list of all the IPs that it owns in a single table. But the interfaces still need information about which network they're connected to. By assigning an IP and network mask to each interface we put this information in one place, simplifying the design. There's no need for extra code to keep the list of IPs consistent with the list of networks that interfaces are connected to.
New contributor
add a comment |
IP addresses include routing information. An IP address is split up into two components, the network number and the host number, based on an assigned prefix length (which was originally expressed as a network mask, and this is still often how it's implemented internally in network stacks).
For routing to work properly, all the devices connected to a particular network must have addresses with the same network number. Senders determine whether the receiver is on the same or a different network by comparing their own network number with the receiver's address. If they're in the same network, they send directly; otherwise, they send to a router whose job is to get the message closer to the destination.
So if a device is connected to multiple networks, it needs an address on each of those networks so it can be reached by devices on that network.
That said, it isn't really necessary for the addresses to be assigned specifically to particular network interfaces. The device could just have a list of all the IPs that it owns in a single table. But the interfaces still need information about which network they're connected to. By assigning an IP and network mask to each interface we put this information in one place, simplifying the design. There's no need for extra code to keep the list of IPs consistent with the list of networks that interfaces are connected to.
New contributor
add a comment |
IP addresses include routing information. An IP address is split up into two components, the network number and the host number, based on an assigned prefix length (which was originally expressed as a network mask, and this is still often how it's implemented internally in network stacks).
For routing to work properly, all the devices connected to a particular network must have addresses with the same network number. Senders determine whether the receiver is on the same or a different network by comparing their own network number with the receiver's address. If they're in the same network, they send directly; otherwise, they send to a router whose job is to get the message closer to the destination.
So if a device is connected to multiple networks, it needs an address on each of those networks so it can be reached by devices on that network.
That said, it isn't really necessary for the addresses to be assigned specifically to particular network interfaces. The device could just have a list of all the IPs that it owns in a single table. But the interfaces still need information about which network they're connected to. By assigning an IP and network mask to each interface we put this information in one place, simplifying the design. There's no need for extra code to keep the list of IPs consistent with the list of networks that interfaces are connected to.
New contributor
IP addresses include routing information. An IP address is split up into two components, the network number and the host number, based on an assigned prefix length (which was originally expressed as a network mask, and this is still often how it's implemented internally in network stacks).
For routing to work properly, all the devices connected to a particular network must have addresses with the same network number. Senders determine whether the receiver is on the same or a different network by comparing their own network number with the receiver's address. If they're in the same network, they send directly; otherwise, they send to a router whose job is to get the message closer to the destination.
So if a device is connected to multiple networks, it needs an address on each of those networks so it can be reached by devices on that network.
That said, it isn't really necessary for the addresses to be assigned specifically to particular network interfaces. The device could just have a list of all the IPs that it owns in a single table. But the interfaces still need information about which network they're connected to. By assigning an IP and network mask to each interface we put this information in one place, simplifying the design. There's no need for extra code to keep the list of IPs consistent with the list of networks that interfaces are connected to.
New contributor
New contributor
answered 5 hours ago
BarmarBarmar
1012
1012
New contributor
New contributor
add a comment |
add a comment |
Tiago Oliveira is a new contributor. Be nice, and check out our Code of Conduct.
Tiago Oliveira is a new contributor. Be nice, and check out our Code of Conduct.
Tiago Oliveira is a new contributor. Be nice, and check out our Code of Conduct.
Tiago Oliveira is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Network Engineering Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fnetworkengineering.stackexchange.com%2fquestions%2f56156%2fwhy-are-ip-addresses-given-to-each-interface-and-not-device-what-would-the-impl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Some devices do only get an IP for management that it isn't tied to any particular interface. Others work in the way you described. It varies by device, model, and software/firmware. In addition, you may need to assign different IP address per interface depending on a task's requirements.
– Jesse P.
16 hours ago
1
Short answer - to make routers possible. A router is just a computer (these days most likely Linux) that needs to connect to different networks - thus must have the ability to have multiple IP addresses. The multiple IP per device thing came about at roughly the same time as the invention of the router.
– slebetman
12 hours ago