Home > Article > Operation and Maintenance > How to set the default gateway in linux
Step one: Use xshell to log in to our linux server.
Step 2: Use route -n to view the routing table of this machine and see that this machine does not have a default route.
The third step: Use ip add to check the local machine address. The local machine is 192.168.101.2, and set the planned gateway to 192.168.101.254
Step 4: Manually add a route.
route add default gw 192.168.101.254 to add a default gateway, and then route -n to see that the route has taken effect
Step 5: Use route add The added command only takes effect temporarily and will be lost after restarting. It needs to be written into the configuration file. It can take effect permanently according to the following configuration.
vim /etc/sysconfig/network
GATEWAY=192.168.101.254
The above is the detailed content of How to set the default gateway in linux. For more information, please follow other related articles on the PHP Chinese website!