5

Im trying to find the default Gateway of machine but see multiple interfaces.

Also, when I find my ipaddress frm the below website it gives me a different ip address. I thought the default Gateway and external ip will be same? Correct me if Im wrong.

https://www.privateinternetaccess.com/pages/whats-my-ip/

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.2.0.0        192.168.255.9   255.255.255.0   UG    0      0        0 tun0
192.168.33.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.255.1   192.168.255.9   255.255.255.255 UGH   0      0        0 tun0
192.168.255.5   0.0.0.0         255.255.255.255 UH    0      0        0 tun4
192.168.255.5   0.0.0.0         255.255.255.255 UH    0      0        0 tun6
192.168.255.5   0.0.0.0         255.255.255.255 UH    0      0        0 tun5
192.168.255.5   0.0.0.0         255.255.255.255 UH    0      0        0 tun2
192.168.255.9   0.0.0.0         255.255.255.255 UH    0      0        0 tun0
192.168.255.13  0.0.0.0         255.255.255.255 UH    0      0        0 tun3
192.168.255.13  0.0.0.0         255.255.255.255 UH    0      0        0 tun1

netstart -r

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         10.0.2.2        0.0.0.0         UG        0 0          0 eth0
10.0.2.0        *               255.255.255.0   U         0 0          0 eth0
10.2.0.0        192.168.255.5   255.255.255.0   UG        0 0          0 tun6
192.168.33.0    *               255.255.255.0   U         0 0          0 eth1
192.168.255.1   192.168.255.5   255.255.255.255 UGH       0 0          0 tun6
192.168.255.5   *               255.255.255.255 UH        0 0          0 tun6
192.168.255.5   *               255.255.255.255 UH        0 0          0 tun3
192.168.255.5   *               255.255.255.255 UH        0 0          0 tun2
192.168.255.5   *               255.255.255.255 UH        0 0          0 tun4
192.168.255.9   *               255.255.255.255 UH        0 0          0 tun5
192.168.255.13  *               255.255.255.255 UH        0 0          0 tun0
192.168.255.13  *               255.255.255.255 UH        0 0          0 tun1
7

destination 0.0.0.0 and genmask 0.0.0.0 matches any other packet which is not defined in routing tables (last way out), so your default gateway is: 10.0.2.2.

You can also use:

$ ip r | grep ^def
default via 192.168.1.1 dev enp3s0  proto static  metric 100

I thought the default Gateway and external ip will be same.

Not true, for example you can forward your traffic to your router with an internal IP address but your the router will replace the source address with its own public IP (NAT).

| improve this answer | |
  • Or to get just the IP: ip route | awk '/default/ {print $3; exit}' – Pablo Bianchi yesterday
0

The easiest way is to pull down the network menu and select Connection Information and look at the gateway address there.

Otherwise, in terminal you can type netstat -r and the first line which says default is where you'll see the gateway address.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.