How to modify the gateway in linux

WBOY
Release: 2022-01-27 15:00:43
Original
18812 people have browsed it

In Linux, you can modify the "GATEWAY" item in the "/etc/sysconfig/network" file to modify the gateway. The syntax is "sudo nano /etc/network/interfaces".

How to modify the gateway in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to modify the gateway in Linux

Open the terminal. You can open the Terminal program from the sidebar or press Ctrl Alt T to open it.

2. Browse the current default gateway information. You can enter route and press Enter to view the current default gateway settings. The address next to "Default" displays the current default gateway address, and the interface it is assigned to is displayed on the right side of the desktop.

3. Delete the current default gateway. If there are multiple default gateways, you may encounter connection conflicts. If you want to change it, delete the existing default gateway. Enter sudo route delete default gw IP Address Adapter. For example, if you want to delete the default gateway 10.0.2.2 on the eth0 adapter, enter sudo route delete default gw 10.0.2.2 eth0.

4. Enter .sudo route add default gw IP Address Adapter. For example, to change the default gateway of the eth0 adapter to 192.168.1.254, you would enter sudo route add default gw 192.168.1.254 eth0. You need to enter your user password to complete the command.

How to modify the gateway in linux

Edit configuration file

1. Open the configuration file in the editor. Enter sudo nano /etc/network/interfaces in the Nano editor to open the file. Editing the configuration file causes the system to retain your changes each time the system is restarted.

2. Find the correct part. Find the adapter section where you need to change the default gateway settings. For wired network connections, this is usually eth0.

3. Add .gateway IP Address to this part. For example, enter gateway 192.168.1.254 to change the default gateway to 192.168.1.254.

How to modify the gateway in linux

4. Save changes and exit. Press Ctrl X then Y to save changes and exit.

5. Restart the network. Enter sudo /etc/init.d/networking restart to restart the network.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to modify the gateway in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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