Home>Article>Operation and Maintenance> How to set the default gateway in linux

How to set the default gateway in linux

PHPz
PHPz forward
2023-05-13 13:01:34 5796browse

Steps to add and set the default gateway for linux

Step one: Usexshellto log in to our linux server.

How to set the default gateway in linux

Step 2: Useroute -nto view the routing table of this machine and see that this machine does not have a default route.

How to set the default gateway in linux

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

How to set the default gateway in linux

Step 4:Manually adda 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

How to set the default gateway in linux

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

How to set the default gateway in linux

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete