Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the default gateway in Linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to change the default gateway in the Linux system. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

I. use the terminal

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

2. Browse the current default gateway information. You can type 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 to which it is assigned is displayed on the right side of the desktop.

3. Delete the current default gateway. If you have multiple default gateways, you will encounter connection conflicts. If you want to change it, please 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, if you want the default gateway for the eth0 adapter to be changed to 192.168.1.254, you can type sudo route add default gw 192.168.1.254 eth0. You need to enter the user's password to complete the command.

Second, edit the configuration file

1. Open the configuration file in the editor. Type sudo nano / etc/network/interfaces in the Nano editor to open the file. Editing the configuration file will allow the system to retain your changes each time the system is rebooted.

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

3. Add .gateway IP Address to this section. For example, enter gateway 192.168.1.254 to make the default gateway 192.168.1.254.

4. Save your changes and exit. Press Ctrl+X, then press Y to save the changes and exit.

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

The above is how to change the default gateway in the Linux system. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report