Category Archives: Network

Find out your gateway IP address

There are two ways of collecting the IP address of your current Gateway:

  1. netstat -r
  2. route -n

The output of both commands are the almost the same:

12:29:25 ✔ dbkreling:~$ sudo netstat -r
[sudo] password for dbkreling:
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.0.1     0.0.0.0         UG        0 0          0 wlan0
172.17.0.0      *               255.255.0.0     U         0 0          0 docker0
192.168.0.0     *               255.255.255.0   U         0 0          0 wlan0

12:29:36 ✔ dbkreling:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0

In my case above IP 192.168.0.1 is the gateway for my connection. The flag U indicates that route is up and G indicates that it is gateway.

Cheers!

 

Advertisements