Home  >  Article  >  System Tutorial  >  What is the method to modify the default gateway of Linux system?

What is the method to modify the default gateway of Linux system?

WBOY
WBOYforward
2024-01-08 14:14:121352browse

The default gateway is the IP address of the router. Generally speaking, the operating system automatically detects the gateway during the installation of the router, but you may also need to change it manually. Especially when there are multiple network adapters or routers in the network, it is often necessary to manually add or change the gateway. How to modify it? Let’s take a look at the detailed tutorial below.

1. Using the terminal

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

What is the method to modify the default gateway of Linux system?

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.

What is the method to modify the default gateway of Linux system?

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.

What is the method to modify the default gateway of Linux system?

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.

What is the method to modify the default gateway of Linux system?

2. Edit the 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.

What is the method to modify the default gateway of Linux system?

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.

What is the method to modify the default gateway of Linux system?

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.

What is the method to modify the default gateway of Linux system?

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

What is the method to modify the default gateway of Linux system?

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

What is the method to modify the default gateway of Linux system?

The above is the detailed content of What is the method to modify the default gateway of Linux system?. For more information, please follow other related articles on the PHP Chinese website!

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