How to set the default gateway (route) this tutorial shows you the command line method of setting the default gateway on CentOS.
Fedora, RHEL / Centos set default gateway tutorial
There is no specific command on CentOS to set the default route or gateway, there are several ways to do this on CentOS (as there often are). The method I am showing you will work on all versions of CentOS with or without a GUI and involves directly editing the network configuration file using Vi.
Setting default gateway on CentOS first requires us to open the “/etc/sysconfig/network” config file using Vi:
1
|
|
You now need to add your default GW, if you don’t know the IP of your default GW (aka default route) then you need to ask your ISP / web host or network admin. The example below assumes our default GW is 192.168.1.1
1
|
|
I always append this information to the bottom on the network config file on CentOS.
After adding the default route (GW) you need to restart the networking service using:
1
|
|
Or
1
|
|