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

How to set the default gateway in linux

PHPz
Release: 2023-05-13 13:01:34
forward
5907 people have browsed it

Steps to add and set the default gateway for linux

Step one: Use xshell to log in to our linux server.

How to set the default gateway in linux

Step 2: Use route -n to 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 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

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template