find router ip | default gateway ip
 

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 10.0.0.138 dev enp3s0
10.0.0.0/24 dev enp3s0 proto kernel scope link src 10.0.0.6
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
0.0.0.0         10.0.0.138      0.0.0.0         UG    0      0        0 enp3s0
10.0.0.0        0.0.0.0         255.255.255.0   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:
traceroute google.com
and look for the first hop.
 
 
Disclaimer Privacy