LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   how to find out the gateways IP? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-find-out-the-gateways-ip-525774/)

Shioni 02-05-2007 10:06 AM

how to find out the gateways IP?
 
Hi!
ifconfig doesn't list the gateway's IP? How can I found out gateways IP? Thank you!

Micro420 02-05-2007 10:31 AM

use the route command
Code:

route
Or go to a website like

http://whatismyip.com

or use tracepath
Code:

tracepath google.com

chort 02-05-2007 01:12 PM

Code:

netstat -ran
Will show your gateways for any configured routes (including the default route). This assumes that have already configured your gateway correctly or received it from DHCP.

If you're asking "how do I find out what my gateway should be" then you need to ask your network administrator. There's no way to find out what you should set it to if it's not already set and/or cannot be discovered with DHCP.

Shioni 02-05-2007 02:37 PM

Thanks! it's working!
Quote:

Originally Posted by chort
Code:

netstat -ran
If you're asking "how do I find out what my gateway should be" then you need to ask your network administrator. There's no way to find out what you should set it to if it's not already set and/or cannot be discovered with DHCP.

No, I just wanted to find out the existing one. Thanks!

chort 02-05-2007 06:45 PM

Quote:

Originally Posted by Shioni
Thanks! it's working!

No, I just wanted to find out the existing one. Thanks!

Well in case it wasn't obvious, you can find that out with netstat. Here's an example from my network:
Code:

chort@twdemos:~> netstat -ran
Kernel IP routing table
Destination    Gateway        Genmask        Flags  MSS Window  irtt Iface
172.22.2.0      0.0.0.0        255.255.255.128 U        0 0          0 eth0
172.16.38.0    0.0.0.0        255.255.255.0  U        0 0          0 vmnet1
192.168.134.0  0.0.0.0        255.255.255.0  U        0 0          0 vmnet8
192.168.1.0    0.0.0.0        255.255.255.0  U        0 0          0 eth1
169.254.0.0    0.0.0.0        255.255.0.0    U        0 0          0 eth1
127.0.0.0      0.0.0.0        255.0.0.0      U        0 0          0 lo
0.0.0.0        172.22.2.1      0.0.0.0        UG        0 0          0 eth0

The last line above that starts 0.0.0.0 is the "default route", i.e. your "gateway" for all traffic that hasn't been specifically routed otherwise. The second column shows the gateway IP (in this case it's 172.22.2.1).


All times are GMT -5. The time now is 03:11 PM.