Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

how can I find the default gateway of an ubuntu box

share|improve this question

3 Answers 3

up vote 9 down vote accepted

Classic answer


Look for a line that says something like:

default         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 dev eth0
share|improve this answer
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
for ipv6 use ip -6 route –  engineerDave Sep 24 at 17:36

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).

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

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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