Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Adding/Deleting gateway for VPS  (Read 6603 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
Adding/Deleting gateway for VPS
« on: October 22, 2013, 12:11:40 pm »
Hi, Gateway is essential in setting up network in a Unix as well as Windows based machine. This gateway can be added/removed as per our wish and current network conditions. Here I am listing some useful commands to set up gateway IP.

Add Route


# route add default gw GATEWAY_IP eth0

Delete Route


# route del default gw GATEWAY_IP

Check Routing Table


# route -n


# netstat -r -n

Sample Output :

Kernel IP routing table

Destination     Gateway         Genmask          Flags  MSS Window  irtt  Iface              UG         0  0             0  eth0        U           0  0             0  eth0    U            0  0             0  eth0

Destination -- Destination host/network.

Gateway -- Gateway address.

Genmask -- Netmask for the destination net.

Flags :

U - route is up

H - target is a host

G  -use gateway

You can also use the "ip" command to do the same.

View / Display Routing Table

# ip route show

In the output, You will have a bunch of entries and each entry is nothing but an entry in the routing table (Linux kernel routing table). For example, All network packets to a system in the same network are sent directly through the device eth0: dev eth0  proto kernel  scope link  src IP_Address

Set a default route

#ip route add default via gateway_ip

Delete route from table

#ip route delete dev eth0

Thats it  8)