Get gateway address of non default interface

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have three interfaces connected to my machine. How can I get the gateway IP of one non default interface? I'm using Debian 9







share|improve this question























    up vote
    0
    down vote

    favorite












    I have three interfaces connected to my machine. How can I get the gateway IP of one non default interface? I'm using Debian 9







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have three interfaces connected to my machine. How can I get the gateway IP of one non default interface? I'm using Debian 9







      share|improve this question











      I have three interfaces connected to my machine. How can I get the gateway IP of one non default interface? I'm using Debian 9









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 22 at 4:09









      david

      1




      1




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          "Gateways" are part of the routing. (Actually, the routing algorithm just wants to know where to send a particular packet (next hop), it doesn't care if the next hop is something you'd call a "gateway", or just a normal host).



          So use ip route to see your routing table. If you don't know the address ranges, use ip addr to see them. All routes that have next hops in the address range of some interface will be "gateway" candidates.



          You can also use ip route get 1.2.3.4 to see to which next hop a packet with this final destination will be sent. This might be more convenient.



          Edit



          Just in case, a short reminder of what happens behind the scenes:



          When a host connects to a LAN segment, and can send out a DHCP broadcast to acquire an IP address. ("Hello, I'm new here, what IP address should I use?"). The DHCP server in the LAN segment (e.g. your home router) then answers "Welcome, use this IP address, and by the way, if you want to reach the internet from this segment, please use this gateway address as next hop."



          The typical reaction to this gateway address announcement is that the host sets the default route to this address.



          If you are connected to three LAN segments, each with their own DHCP server, and each with a connection to the internet via a gatway (which shouldn't happen in a professionally designed network), then the host will receive three DHCP answers with different gateways, will set the default route each time, and the last wins. Note that there is no "default interface".



          So if your situation is not that you are part of a corporate network with different next hops in each segment on each interface, but you are accidentally connected to three standard home networks, where no one has bothered to set up the right infrastructure for such a case, and you want to know the announced gateway in the DHCP answers, you can (1) look in the logs for DHCP answers, (2) disconnect all three interfaces, re-connect each in turn, get a new DHCP answer and write down the default route, (3) use a tool to debug DHCP requests, so you can send out an additional one.



          Note that this information will be of no use to you: You can only use one default route, and you can't use different gateways into the internet to somehow get faster speeds etc.






          share|improve this answer























            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451219%2fget-gateway-address-of-non-default-interface%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            "Gateways" are part of the routing. (Actually, the routing algorithm just wants to know where to send a particular packet (next hop), it doesn't care if the next hop is something you'd call a "gateway", or just a normal host).



            So use ip route to see your routing table. If you don't know the address ranges, use ip addr to see them. All routes that have next hops in the address range of some interface will be "gateway" candidates.



            You can also use ip route get 1.2.3.4 to see to which next hop a packet with this final destination will be sent. This might be more convenient.



            Edit



            Just in case, a short reminder of what happens behind the scenes:



            When a host connects to a LAN segment, and can send out a DHCP broadcast to acquire an IP address. ("Hello, I'm new here, what IP address should I use?"). The DHCP server in the LAN segment (e.g. your home router) then answers "Welcome, use this IP address, and by the way, if you want to reach the internet from this segment, please use this gateway address as next hop."



            The typical reaction to this gateway address announcement is that the host sets the default route to this address.



            If you are connected to three LAN segments, each with their own DHCP server, and each with a connection to the internet via a gatway (which shouldn't happen in a professionally designed network), then the host will receive three DHCP answers with different gateways, will set the default route each time, and the last wins. Note that there is no "default interface".



            So if your situation is not that you are part of a corporate network with different next hops in each segment on each interface, but you are accidentally connected to three standard home networks, where no one has bothered to set up the right infrastructure for such a case, and you want to know the announced gateway in the DHCP answers, you can (1) look in the logs for DHCP answers, (2) disconnect all three interfaces, re-connect each in turn, get a new DHCP answer and write down the default route, (3) use a tool to debug DHCP requests, so you can send out an additional one.



            Note that this information will be of no use to you: You can only use one default route, and you can't use different gateways into the internet to somehow get faster speeds etc.






            share|improve this answer



























              up vote
              0
              down vote













              "Gateways" are part of the routing. (Actually, the routing algorithm just wants to know where to send a particular packet (next hop), it doesn't care if the next hop is something you'd call a "gateway", or just a normal host).



              So use ip route to see your routing table. If you don't know the address ranges, use ip addr to see them. All routes that have next hops in the address range of some interface will be "gateway" candidates.



              You can also use ip route get 1.2.3.4 to see to which next hop a packet with this final destination will be sent. This might be more convenient.



              Edit



              Just in case, a short reminder of what happens behind the scenes:



              When a host connects to a LAN segment, and can send out a DHCP broadcast to acquire an IP address. ("Hello, I'm new here, what IP address should I use?"). The DHCP server in the LAN segment (e.g. your home router) then answers "Welcome, use this IP address, and by the way, if you want to reach the internet from this segment, please use this gateway address as next hop."



              The typical reaction to this gateway address announcement is that the host sets the default route to this address.



              If you are connected to three LAN segments, each with their own DHCP server, and each with a connection to the internet via a gatway (which shouldn't happen in a professionally designed network), then the host will receive three DHCP answers with different gateways, will set the default route each time, and the last wins. Note that there is no "default interface".



              So if your situation is not that you are part of a corporate network with different next hops in each segment on each interface, but you are accidentally connected to three standard home networks, where no one has bothered to set up the right infrastructure for such a case, and you want to know the announced gateway in the DHCP answers, you can (1) look in the logs for DHCP answers, (2) disconnect all three interfaces, re-connect each in turn, get a new DHCP answer and write down the default route, (3) use a tool to debug DHCP requests, so you can send out an additional one.



              Note that this information will be of no use to you: You can only use one default route, and you can't use different gateways into the internet to somehow get faster speeds etc.






              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                "Gateways" are part of the routing. (Actually, the routing algorithm just wants to know where to send a particular packet (next hop), it doesn't care if the next hop is something you'd call a "gateway", or just a normal host).



                So use ip route to see your routing table. If you don't know the address ranges, use ip addr to see them. All routes that have next hops in the address range of some interface will be "gateway" candidates.



                You can also use ip route get 1.2.3.4 to see to which next hop a packet with this final destination will be sent. This might be more convenient.



                Edit



                Just in case, a short reminder of what happens behind the scenes:



                When a host connects to a LAN segment, and can send out a DHCP broadcast to acquire an IP address. ("Hello, I'm new here, what IP address should I use?"). The DHCP server in the LAN segment (e.g. your home router) then answers "Welcome, use this IP address, and by the way, if you want to reach the internet from this segment, please use this gateway address as next hop."



                The typical reaction to this gateway address announcement is that the host sets the default route to this address.



                If you are connected to three LAN segments, each with their own DHCP server, and each with a connection to the internet via a gatway (which shouldn't happen in a professionally designed network), then the host will receive three DHCP answers with different gateways, will set the default route each time, and the last wins. Note that there is no "default interface".



                So if your situation is not that you are part of a corporate network with different next hops in each segment on each interface, but you are accidentally connected to three standard home networks, where no one has bothered to set up the right infrastructure for such a case, and you want to know the announced gateway in the DHCP answers, you can (1) look in the logs for DHCP answers, (2) disconnect all three interfaces, re-connect each in turn, get a new DHCP answer and write down the default route, (3) use a tool to debug DHCP requests, so you can send out an additional one.



                Note that this information will be of no use to you: You can only use one default route, and you can't use different gateways into the internet to somehow get faster speeds etc.






                share|improve this answer















                "Gateways" are part of the routing. (Actually, the routing algorithm just wants to know where to send a particular packet (next hop), it doesn't care if the next hop is something you'd call a "gateway", or just a normal host).



                So use ip route to see your routing table. If you don't know the address ranges, use ip addr to see them. All routes that have next hops in the address range of some interface will be "gateway" candidates.



                You can also use ip route get 1.2.3.4 to see to which next hop a packet with this final destination will be sent. This might be more convenient.



                Edit



                Just in case, a short reminder of what happens behind the scenes:



                When a host connects to a LAN segment, and can send out a DHCP broadcast to acquire an IP address. ("Hello, I'm new here, what IP address should I use?"). The DHCP server in the LAN segment (e.g. your home router) then answers "Welcome, use this IP address, and by the way, if you want to reach the internet from this segment, please use this gateway address as next hop."



                The typical reaction to this gateway address announcement is that the host sets the default route to this address.



                If you are connected to three LAN segments, each with their own DHCP server, and each with a connection to the internet via a gatway (which shouldn't happen in a professionally designed network), then the host will receive three DHCP answers with different gateways, will set the default route each time, and the last wins. Note that there is no "default interface".



                So if your situation is not that you are part of a corporate network with different next hops in each segment on each interface, but you are accidentally connected to three standard home networks, where no one has bothered to set up the right infrastructure for such a case, and you want to know the announced gateway in the DHCP answers, you can (1) look in the logs for DHCP answers, (2) disconnect all three interfaces, re-connect each in turn, get a new DHCP answer and write down the default route, (3) use a tool to debug DHCP requests, so you can send out an additional one.



                Note that this information will be of no use to you: You can only use one default route, and you can't use different gateways into the internet to somehow get faster speeds etc.







                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jun 22 at 7:28


























                answered Jun 22 at 6:46









                dirkt

                13.9k2930




                13.9k2930






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451219%2fget-gateway-address-of-non-default-interface%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?