how can I find the default gateway of an ubuntu box

link|improve this question

50% accept rate
feedback

3 Answers

up vote 8 down vote accepted

Classic answer

route

Look for a line that says something like:

default         10.63.3.254     0.0.0.0         UG    0      0        0 eth0

The second column contains the default gateway, and the last column is the interface.

You can also use the ip command:

ip route

which will give you something like

default via 10.63.3.254 dev eth0
link|improve this answer
2  
Note that the ip route is the currently preferred way of extracting such information. The old route command is kept for compatibility. Also, you can see the IPv6 default route using ip -6 route. – Juliano Jul 13 '09 at 17:00
you are correct... but I'm a sucker for old school commands ;) – Mikeage Jul 14 '09 at 2:28
feedback

You can also use "netstat -nr" (I usually leave the n in the flags, so as to not have to wait for host resolution if there's a DNS issue).

link|improve this answer
feedback
grog:/var/log# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

You can also check /etc/network/interfaces to see what it'll be on next reboot or networking restart.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.