Category:  Articles
 Publish Date: 
 Views:  2997
How To Add Or Change Default Gateway In Linux
How To Add Or Change Default Gateway In Linux

You can use Command line for adding or changing the default gateway in Linux, follow the simple steps below.

Know the required command. The syntax is as follows:

  • route add default gw {IP-ADDRESS} {INTERFACE-NAME}
  • IP-ADDRESS=router IP Address INTERFACE-NAME= interface name such as eth0 (but may not be needed)
  • Example: router IP address is 192.168.1.251

Login as root user:

  • # route add default gw 192.168.1.251 eth0

Or use hostname such as home-router eth0

  • # route add default gw home-router eth0