How To Add Or Change Default Gateway In Linux

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

Help Us Grow

If you like this post, please share it with your friends.

You are free to copy and redistribute this article in any medium or format, as long as you keep the links in the article or provide a link back to this page.

Subscribe to our mailing list

You may also like...