Find out Gateway / router IP address under Linux / UNIX using route command

You need to use route command. This command can manipulates the kernel’s IP routing tables. It can be also use to print gateway / router IP address. Type the following command to see default gateway:
$ route -n
Output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.10.54      0.0.0.0         255.255.255.0   U     0      0        0 ra0
0.0.0.0         10.0.10.1       0.0.0.0         UG    0      0        0 ra0

192.168.1.1 is gateway IP address for our computer. The flag U indicates that route is up and G indicates that it is gateway. You can print gateway name, enter:
$ route
Output:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.10.1    *               255.255.255.0   U     0      0        0 ra0
default         wrt             0.0.0.0         UG    0      0        0 ra0

Second column prints Gateway hostname / IP address. In our example wrt is gateway.

netstat command example to find out gateway/router IP

Open a terminal and type the following command:
# netstat -r -n
Sample outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.10.1   0.0.0.0         UG        0 0          0 eth1
10.0.10.1     0.0.0.0         255.255.255.0   U         0 0          0 eth1

One thought on “Find out Gateway / router IP address under Linux / UNIX using route command

  • June 23, 2014 at 3:27 am
    Permalink

    Thanks for taking the time to discuss this, I truly feel strongly about it and really like learning extra on this subject. If attainable, as you obtain experience, would you thoughts updating your blog with additional data? It truly is really useful for me.
    Sac Messenger Longchamp
    [url=http://iconito.ac-montpellier.fr/index/Sac-Messenger-Longchamp.php]Sac Messenger Longchamp[/url]

Leave a Reply