Ubuntu Linux: Find Out Default Gateway

by on July 1, 2009 · 1 comment· LAST UPDATED July 1, 2010

in

How do I find out default gateway IP address (default router IP assigned) for my Ubuntu Linux systems?

Use the route or ip command to get default routing table for Ubuntu Linux. Open the terminal and type the following command:
route -n
Sample outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     0.0.0.0         255.255.255.0   U     2      0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
0.0.0.0         192.168.2.1     0.0.0.0         UG    0      0        0 wlan0

Destination for 0.0.0.0 is set to 192.168.2.1 via wlan0 interface i.e. 192.168.2.1 is default gateway. If you just type the route command with the -n switch it show word default instead of 0.0.0.0:
route
Sample outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     *               255.255.255.0   U     2      0        0 wlan0
192.168.1.0     *               255.255.255.0   U     1      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
link-local      *               255.255.0.0     U     1000   0        0 wlan0
default         192.168.2.1     0.0.0.0         UG    0      0        0 wlan0

ip route Command

The following command does the same thing:
ip route show
Sample outputs:

192.168.2.0/24 dev wlan0  proto kernel  scope link  src 192.168.2.3  metric 2
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.254  metric 1
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1
169.254.0.0/16 dev wlan0  scope link  metric 1000
default via 192.168.2.1 dev wlan0  proto static
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 srinivas June 24, 2013 at 7:23 am

How to find remote systems gateway from server in the same lan .

we have multiple gateways in our network like 192.168.1.1 , 192.168.1.2 and 192.168.1.175 .

how can find out that which system is using which gateway .

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: