Check IP default gateway on Linux 

Joined:
04/07/2009
Posts:
163

June 14, 2011 08:15:57    Last update: June 14, 2011 08:17:25
In below examples, the default gateway is 105.52.84.1.
  1. Use "netstat -rn":
    $ netstat -rn
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    105.52.84.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
    0.0.0.0         105.52.84.1     0.0.0.0         UG        0 0          0 eth0
    

  2. Use "route -n":
    $ route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    105.52.84.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0
    0.0.0.0         105.52.84.1     0.0.0.0         UG    0      0        0 eth0
    

  3. Use "ip route show":
    $ ip route show
    105.52.84.0/24 dev eth0  proto kernel  scope link  src 105.52.84.142  metric 1 
    default via 105.52.84.1 dev eth0  proto static 
    

Share |
| Comment  | Tags