Finding your Router IP (Default Gateway IP) Using the Command Line

There are many ways to find default gateway IP in Linux. If you have the iproute2 package installed, then you may use the ip command, simply run:
$ ip route show
and get something similar to the following output:

default via dev enp3s0 dev enp3s0 proto kernel scope link src
or you can install the net-tools package and run (as root):
# route -n 
and get something similar to:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 enp3s0   U     0      0        0 enp3s0
If you have the net-tools package installed, you can run (as normal user)
$ netstate -rn
and get the same output as before. The net-tools and iproute2 can do lot more than finding the default gateway address, however if neither one of this packages installed, then you can run:
$ cat /proc/net/arp
If you have traceroute package installed, then you can also run:
and look for the first hop.
Disclaimer Privacy