• 欢迎访问速搜资源吧,如果在网站上找不到你需要的资源,可以在留言板上留言,管理员会尽量满足你!

【速搜问答】Linux系统如何添加或更改默认网关

问答 admin 8个月前 (03-25) 182次浏览 已收录 0个评论

汉英对照:
Chinese-English Translation:

默认网关就是路由器的 IP 地址。一般来说,操作系统会在路由器的安装过程中自动检测网关,但是你也可能需要手动更改它。尤其是当网络中有多个网络适配器或路由器时,往往需要手动添加或更改网关。

The default gateway is the IP address of the router. Generally speaking, the operating system will automatically detect 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 gateways.

使用终端

Use terminal

1、打开终端。你可以从边栏打开终端程序,或按下 Ctrl+Alt+T 组合键来打开它。

1. Turn on the terminal. You can open the terminal program from the sidebar, or press Ctrl + Alt + T to open it.

2、浏览当前默认网关信息。你可以输入 route,按下 Enter,来查看当前的默认网关设置。“默认”旁边的地址会显示当前默认的网关地址,它被分配到的界面则显示在桌面右侧。

2. Browse the current default gateway information. You can type route and press enter to see the current default gateway settings. The address next to “default” will display the current default gateway address, and the interface to which it is assigned will be displayed on the right side of the desktop.

3、删除当前的默认网关。如果有多个默认网关,那么会遇到连接冲突的问题。如果你想更改它,请删除现有的默认网关。

3. Delete the current default gateway. If there are multiple default gateways, you will encounter the problem of connection conflict. If you want to change it, remove the existing default gateway.

输入 sudo route delete default gw IP Address Adapter。例如,如果想要删除 eth0 适配器上的默认网关 10.0.2.2,请输入 sudo route delete default gw 10.0.2.2 eth0。

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、输入.sudo route add default gw IP Address Adapter。 例如,想要 eth0 适配器的默认网关更改为 192.168.1.254,你可以输入 sudo route add default gw 192.168.1.254 eth0。你需要输入用户密码,才能完成命令。

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

编辑配置文件

Edit profile

1、在编辑器中打开配置文件。在 Nano 编辑器中输入 sudo nano /etc/network/interfaces 来打开文件。编辑配置文件会让系统在每次重启系统时保留你的更改。

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 allows the system to keep your changes every time you restart the system.

2、找到正确的部分。找到你需要更改默认网关设置的适配器部分。对于有线网络连接来说,通常是 eth0。

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

3、在这个部分加上.gateway IP Address。 例如,输入 gateway 192.168.1.254,让默认网关变成 192.168.1.254。

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、保存更改并退出。按下 Ctrl+X,然后按下 Y 来保存更改并退出。

4. Save your changes and exit. Press Ctrl + X, then y to save your changes and exit.

5、重启网络。输入 sudo /etc/init.d/networking restart 重启网络。

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


速搜资源网 , 版权所有丨如未注明 , 均为原创丨转载请注明原文链接:【速搜问答】Linux系统如何添加或更改默认网关
喜欢 (0)
[361009623@qq.com]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址