Why are IP addresses given to each interface and not device? What would the implications of that be?












11















Why do we need to give IP addresses to each interface? Wouldn't giving one to each device be enough?










share|improve this question




















  • 3





    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.
    Jan 16 at 14:35








  • 3





    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
    Jan 16 at 17:57











  • No answer with historical information? Disappointed :-)

    – DanFromGermany
    Jan 17 at 11:33











  • This question makes no sense, or isn't concrete or complete logical statement. It's just a combination of words. An ip address is a integer used in the internet protocol defined in various requests for comments. I don't believe a notion of "device" or "interface are ever defined.

    – marshal craft
    Jan 17 at 12:14











  • For example two windows application running on the same physical machine can utilize a network which uses ip protocol to communicate. There are pros and cons to this. That said, again the ip protocol is an abstract logical thing which runs on top of the underlying layers which them selves can be abstract the same as IP.

    – marshal craft
    Jan 17 at 12:19
















11















Why do we need to give IP addresses to each interface? Wouldn't giving one to each device be enough?










share|improve this question




















  • 3





    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.
    Jan 16 at 14:35








  • 3





    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
    Jan 16 at 17:57











  • No answer with historical information? Disappointed :-)

    – DanFromGermany
    Jan 17 at 11:33











  • This question makes no sense, or isn't concrete or complete logical statement. It's just a combination of words. An ip address is a integer used in the internet protocol defined in various requests for comments. I don't believe a notion of "device" or "interface are ever defined.

    – marshal craft
    Jan 17 at 12:14











  • For example two windows application running on the same physical machine can utilize a network which uses ip protocol to communicate. There are pros and cons to this. That said, again the ip protocol is an abstract logical thing which runs on top of the underlying layers which them selves can be abstract the same as IP.

    – marshal craft
    Jan 17 at 12:19














11












11








11


4






Why do we need to give IP addresses to each interface? Wouldn't giving one to each device be enough?










share|improve this question
















Why do we need to give IP addresses to each interface? Wouldn't giving one to each device be enough?







routing ip network internet ip-address






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 17 at 18:29









CalvT

105115




105115










asked Jan 16 at 13:59









Tiago OliveiraTiago Oliveira

16427




16427








  • 3





    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.
    Jan 16 at 14:35








  • 3





    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
    Jan 16 at 17:57











  • No answer with historical information? Disappointed :-)

    – DanFromGermany
    Jan 17 at 11:33











  • This question makes no sense, or isn't concrete or complete logical statement. It's just a combination of words. An ip address is a integer used in the internet protocol defined in various requests for comments. I don't believe a notion of "device" or "interface are ever defined.

    – marshal craft
    Jan 17 at 12:14











  • For example two windows application running on the same physical machine can utilize a network which uses ip protocol to communicate. There are pros and cons to this. That said, again the ip protocol is an abstract logical thing which runs on top of the underlying layers which them selves can be abstract the same as IP.

    – marshal craft
    Jan 17 at 12:19














  • 3





    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.
    Jan 16 at 14:35








  • 3





    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
    Jan 16 at 17:57











  • No answer with historical information? Disappointed :-)

    – DanFromGermany
    Jan 17 at 11:33











  • This question makes no sense, or isn't concrete or complete logical statement. It's just a combination of words. An ip address is a integer used in the internet protocol defined in various requests for comments. I don't believe a notion of "device" or "interface are ever defined.

    – marshal craft
    Jan 17 at 12:14











  • For example two windows application running on the same physical machine can utilize a network which uses ip protocol to communicate. There are pros and cons to this. That said, again the ip protocol is an abstract logical thing which runs on top of the underlying layers which them selves can be abstract the same as IP.

    – marshal craft
    Jan 17 at 12:19








3




3





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.
Jan 16 at 14:35







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.
Jan 16 at 14:35






3




3





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
Jan 16 at 17:57





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
Jan 16 at 17:57













No answer with historical information? Disappointed :-)

– DanFromGermany
Jan 17 at 11:33





No answer with historical information? Disappointed :-)

– DanFromGermany
Jan 17 at 11:33













This question makes no sense, or isn't concrete or complete logical statement. It's just a combination of words. An ip address is a integer used in the internet protocol defined in various requests for comments. I don't believe a notion of "device" or "interface are ever defined.

– marshal craft
Jan 17 at 12:14





This question makes no sense, or isn't concrete or complete logical statement. It's just a combination of words. An ip address is a integer used in the internet protocol defined in various requests for comments. I don't believe a notion of "device" or "interface are ever defined.

– marshal craft
Jan 17 at 12:14













For example two windows application running on the same physical machine can utilize a network which uses ip protocol to communicate. There are pros and cons to this. That said, again the ip protocol is an abstract logical thing which runs on top of the underlying layers which them selves can be abstract the same as IP.

– marshal craft
Jan 17 at 12:19





For example two windows application running on the same physical machine can utilize a network which uses ip protocol to communicate. There are pros and cons to this. That said, again the ip protocol is an abstract logical thing which runs on top of the underlying layers which them selves can be abstract the same as IP.

– marshal craft
Jan 17 at 12:19










8 Answers
8






active

oldest

votes


















26














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. Different interfaces often have different functions, so it's important to distinguish between them (e.g. internal console, public services, iSCSI).



Routers require multiple IP addresses for their interfaces.






share|improve this answer

































    14














    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.






    share|improve this answer



















    • 1





      Why couldn't you know what is reachable at each interface without those having different IP addresses?

      – Paŭlo Ebermann
      Jan 17 at 0:17











    • You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

      – Piskvor
      Jan 17 at 9:45






    • 2





      And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

      – Piskvor
      Jan 17 at 9:50



















    5














    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!






    share|improve this answer
























    • 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
      Jan 16 at 22:35





















    3















    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.






    share|improve this answer

































      3














      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.






      share|improve this answer





















      • 1





        Nice and concise answer, very clear way of explaining why.

        – Stilez
        Jan 16 at 19:56



















      2














      In the general case, you do need one IP per local network you connect to, 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.






      share|improve this answer

































        0














        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.






        share|improve this answer































          0














          It might be enough to have one IP in the standard case, but as highlighted by other answers, there are many cases where it's not.



          Other answers have already mentioned the case of a router. One mentions virtualbox, which is the case of virtual machines: you may be running on a single physical device several virtual ones.
          Another case is VLANs, you might have actually, connected to a single network card, several different virtual LANs, with different IP addresses. And you could even for some reasons have an interface with multiple IPs, for instance because you want to run several web servers on TCP port 80. Such a configuration isn't uncommon for servers, the hardware you rent may have a single network interface card, but you will have several IP addresses configured.






          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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

























            8 Answers
            8






            active

            oldest

            votes








            8 Answers
            8






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            26














            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. Different interfaces often have different functions, so it's important to distinguish between them (e.g. internal console, public services, iSCSI).



            Routers require multiple IP addresses for their interfaces.






            share|improve this answer






























              26














              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. Different interfaces often have different functions, so it's important to distinguish between them (e.g. internal console, public services, iSCSI).



              Routers require multiple IP addresses for their interfaces.






              share|improve this answer




























                26












                26








                26







                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. Different interfaces often have different functions, so it's important to distinguish between them (e.g. internal console, public services, iSCSI).



                Routers require multiple IP addresses for their interfaces.






                share|improve this answer















                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. Different interfaces often have different functions, so it's important to distinguish between them (e.g. internal console, public services, iSCSI).



                Routers require multiple IP addresses for their interfaces.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 17 at 18:13

























                answered Jan 16 at 15:27









                Zac67Zac67

                28.5k21558




                28.5k21558























                    14














                    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.






                    share|improve this answer



















                    • 1





                      Why couldn't you know what is reachable at each interface without those having different IP addresses?

                      – Paŭlo Ebermann
                      Jan 17 at 0:17











                    • You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

                      – Piskvor
                      Jan 17 at 9:45






                    • 2





                      And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

                      – Piskvor
                      Jan 17 at 9:50
















                    14














                    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.






                    share|improve this answer



















                    • 1





                      Why couldn't you know what is reachable at each interface without those having different IP addresses?

                      – Paŭlo Ebermann
                      Jan 17 at 0:17











                    • You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

                      – Piskvor
                      Jan 17 at 9:45






                    • 2





                      And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

                      – Piskvor
                      Jan 17 at 9:50














                    14












                    14








                    14







                    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.






                    share|improve this answer













                    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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 16 at 17:06









                    PiskvorPiskvor

                    2414




                    2414








                    • 1





                      Why couldn't you know what is reachable at each interface without those having different IP addresses?

                      – Paŭlo Ebermann
                      Jan 17 at 0:17











                    • You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

                      – Piskvor
                      Jan 17 at 9:45






                    • 2





                      And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

                      – Piskvor
                      Jan 17 at 9:50














                    • 1





                      Why couldn't you know what is reachable at each interface without those having different IP addresses?

                      – Paŭlo Ebermann
                      Jan 17 at 0:17











                    • You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

                      – Piskvor
                      Jan 17 at 9:45






                    • 2





                      And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

                      – Piskvor
                      Jan 17 at 9:50








                    1




                    1





                    Why couldn't you know what is reachable at each interface without those having different IP addresses?

                    – Paŭlo Ebermann
                    Jan 17 at 0:17





                    Why couldn't you know what is reachable at each interface without those having different IP addresses?

                    – Paŭlo Ebermann
                    Jan 17 at 0:17













                    You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

                    – Piskvor
                    Jan 17 at 9:45





                    You could (and it is indeed possible to have such routing rules), but then you're going to a lower level of abstraction, instead of saying "send anything non-matching to 10.1.2.1" and be done with it (OSI layer 3), now you need to handle "which of the interfaces do I want (layer 2)". It is also possible, but the abstraction simplifies matters.

                    – Piskvor
                    Jan 17 at 9:45




                    2




                    2





                    And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

                    – Piskvor
                    Jan 17 at 9:50





                    And another thing - the IP addresses are assigned for others to contact you as well. Say you're connected via wifi and via ethernet; each of the interfaces goes into a different network, but both networks can reach the internet. Now you send out a packet to 1.2.3.4 from your 10.1.2.3 - what's the return route? Wifi or wired? You can guess, but if you guess wrong, the packet comes back through the wrong interface and could be discarded. (Yes, there are cases where you want multiple interfaces with same IP addr, or an iface with more IP addrs, or an iface with no addr at all - unusual)

                    – Piskvor
                    Jan 17 at 9:50











                    5














                    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!






                    share|improve this answer
























                    • 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
                      Jan 16 at 22:35


















                    5














                    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!






                    share|improve this answer
























                    • 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
                      Jan 16 at 22:35
















                    5












                    5








                    5







                    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!






                    share|improve this answer













                    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!







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 16 at 17:19









                    Martin RosenauMartin Rosenau

                    1,04318




                    1,04318













                    • 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
                      Jan 16 at 22:35





















                    • 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
                      Jan 16 at 22:35



















                    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
                    Jan 16 at 22:35







                    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
                    Jan 16 at 22:35













                    3















                    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.






                    share|improve this answer






























                      3















                      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.






                      share|improve this answer




























                        3












                        3








                        3








                        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.






                        share|improve this answer
















                        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.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 16 at 20:26

























                        answered Jan 16 at 19:52









                        David SchwartzDavid Schwartz

                        23116




                        23116























                            3














                            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.






                            share|improve this answer





















                            • 1





                              Nice and concise answer, very clear way of explaining why.

                              – Stilez
                              Jan 16 at 19:56
















                            3














                            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.






                            share|improve this answer





















                            • 1





                              Nice and concise answer, very clear way of explaining why.

                              – Stilez
                              Jan 16 at 19:56














                            3












                            3








                            3







                            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.






                            share|improve this answer















                            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.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 16 at 23:18

























                            answered Jan 16 at 16:02









                            EddieEddie

                            9,20822461




                            9,20822461








                            • 1





                              Nice and concise answer, very clear way of explaining why.

                              – Stilez
                              Jan 16 at 19:56














                            • 1





                              Nice and concise answer, very clear way of explaining why.

                              – Stilez
                              Jan 16 at 19:56








                            1




                            1





                            Nice and concise answer, very clear way of explaining why.

                            – Stilez
                            Jan 16 at 19:56





                            Nice and concise answer, very clear way of explaining why.

                            – Stilez
                            Jan 16 at 19:56











                            2














                            In the general case, you do need one IP per local network you connect to, 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.






                            share|improve this answer






























                              2














                              In the general case, you do need one IP per local network you connect to, 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.






                              share|improve this answer




























                                2












                                2








                                2







                                In the general case, you do need one IP per local network you connect to, 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.






                                share|improve this answer















                                In the general case, you do need one IP per local network you connect to, 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.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jan 17 at 10:40

























                                answered Jan 16 at 18:01









                                jcaronjcaron

                                39119




                                39119























                                    0














                                    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.






                                    share|improve this answer




























                                      0














                                      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.






                                      share|improve this answer


























                                        0












                                        0








                                        0







                                        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.






                                        share|improve this answer













                                        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.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Jan 17 at 1:02









                                        BarmarBarmar

                                        1012




                                        1012























                                            0














                                            It might be enough to have one IP in the standard case, but as highlighted by other answers, there are many cases where it's not.



                                            Other answers have already mentioned the case of a router. One mentions virtualbox, which is the case of virtual machines: you may be running on a single physical device several virtual ones.
                                            Another case is VLANs, you might have actually, connected to a single network card, several different virtual LANs, with different IP addresses. And you could even for some reasons have an interface with multiple IPs, for instance because you want to run several web servers on TCP port 80. Such a configuration isn't uncommon for servers, the hardware you rent may have a single network interface card, but you will have several IP addresses configured.






                                            share|improve this answer




























                                              0














                                              It might be enough to have one IP in the standard case, but as highlighted by other answers, there are many cases where it's not.



                                              Other answers have already mentioned the case of a router. One mentions virtualbox, which is the case of virtual machines: you may be running on a single physical device several virtual ones.
                                              Another case is VLANs, you might have actually, connected to a single network card, several different virtual LANs, with different IP addresses. And you could even for some reasons have an interface with multiple IPs, for instance because you want to run several web servers on TCP port 80. Such a configuration isn't uncommon for servers, the hardware you rent may have a single network interface card, but you will have several IP addresses configured.






                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                It might be enough to have one IP in the standard case, but as highlighted by other answers, there are many cases where it's not.



                                                Other answers have already mentioned the case of a router. One mentions virtualbox, which is the case of virtual machines: you may be running on a single physical device several virtual ones.
                                                Another case is VLANs, you might have actually, connected to a single network card, several different virtual LANs, with different IP addresses. And you could even for some reasons have an interface with multiple IPs, for instance because you want to run several web servers on TCP port 80. Such a configuration isn't uncommon for servers, the hardware you rent may have a single network interface card, but you will have several IP addresses configured.






                                                share|improve this answer













                                                It might be enough to have one IP in the standard case, but as highlighted by other answers, there are many cases where it's not.



                                                Other answers have already mentioned the case of a router. One mentions virtualbox, which is the case of virtual machines: you may be running on a single physical device several virtual ones.
                                                Another case is VLANs, you might have actually, connected to a single network card, several different virtual LANs, with different IP addresses. And you could even for some reasons have an interface with multiple IPs, for instance because you want to run several web servers on TCP port 80. Such a configuration isn't uncommon for servers, the hardware you rent may have a single network interface card, but you will have several IP addresses configured.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jan 17 at 8:46









                                                user1532080user1532080

                                                1211




                                                1211






























                                                    draft saved

                                                    draft discarded




















































                                                    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.




                                                    draft saved


                                                    draft discarded














                                                    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





















































                                                    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







                                                    Popular posts from this blog

                                                    Mario Kart Wii

                                                    What does “Dominus providebit” mean?

                                                    Antonio Litta Visconti Arese