Get gateway address of non default interface
Clash 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
linux debian networking
add a comment |Â
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
linux debian networking
add a comment |Â
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
linux debian networking
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
linux debian networking
asked Jun 22 at 4:09
david
1
1
add a comment |Â
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
"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.
edited Jun 22 at 7:28
answered Jun 22 at 6:46
dirkt
13.9k2930
13.9k2930
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password