如何在linux中添加或改变默认网关(add or change the default gateway in linux)

你的默认网关是你的路由器的IP地址。通常情况下,这是在安装过程中由你的操作系统自动检测出来的,但你可能需要改变它。如果你在网络上有多个网络适配器或路由器,这一点尤其正确。...

第1部分第2部分:使用终端

  1. 1打开终端。你可以从侧边栏打开终端,或者按Ctrl+Alt+T。
  2. Image titled Add or Change the Default Gateway in Linux Step 1
  3. 2查看你当前的默认网关。你可以通过输入route并按↵Enter键来检查你的默认网关设置为什么。默认 "旁边的地址显示你的默认网关,它所分配的接口显示在表格的右边。
  4. Image titled Add or Change the Default Gateway in Linux Step 2
  5. 3、删除你当前的默认网关。如果你有一个以上的默认网关设置,你会遇到连接冲突。如果你打算改变现有的默认网关,请删除它。输入sudo route delete default gw IP地址适配器。例如,要删除eth0适配器上的默认网关10.0.2.2,输入sudo route delete default gw 10.0.2.2 eth0。
  6. Image titled Add or Change the Default Gateway in Linux Step 3
  7. 4键入.sudo route add default gw IP地址适配器。例如,要改变eth0适配器的默认网关为192.168.1.254,你可以输入sudo route add default gw 192.168.1.254 eth0。为了完成这个命令,系统会提示你输入用户密码。
  8. Image titled Add or Change the Default Gateway in Linux Step 4

第二部分第二部分:编辑你的配置文件

  1. 1 在一个编辑器中打开配置文件。输入sudo nano /etc/network/interfaces,在nano编辑器中打开该文件。编辑你的配置文件将在每次系统重启时保留你的修改。
  2. Image titled Add or Change the Default Gateway in Linux Step 5
  3. 2浏览到正确的章节。找到你想改变默认网关的适配器的部分。对于有线连接,这通常是eth0。
  4. Image titled Add or Change the Default Gateway in Linux Step 6
  5. 3在该部分添加.gateway IP地址。例如,输入gateway 192.168.1.254,使默认网关为192.168.1.254。
  6. Image titled Add or Change the Default Gateway in Linux Step 7
  7. 4.保存你的修改并退出。按Ctrl+X,然后按Y来保存你的改变并退出。
  8. Image titled Add or Change the Default Gateway in Linux Step 8
  9. 5重新启动你的网络。通过输入sudo /etc/init.d/networking restart,重新启动你的网络。
  10. Image titled Add or Change the Default Gateway in Linux Step 9
  • 发表于 2022-03-02 14:54
  • 阅读 ( 67 )
  • 分类:IT

你可能感兴趣的文章

40多个最常用的linux终端命令

... 在您真正充分利用终端之前,您需要知道如何导航它。这就是为什么我们认为这些是最基本的Linux命令:如果你不能更改目录或者在一个你不记得如何使用的命令上获得帮助,那么再多的终端知识也帮不了你。 ...

  • 发布于 2021-03-15 21:40
  • 阅读 ( 271 )

如何使用steam play在linux上玩几乎所有windows游戏

... 下面介绍如何在Linux上使用测试版的Steam play玩Windows游戏。 ...

  • 发布于 2021-03-23 19:13
  • 阅读 ( 369 )

如何在linux上管理ip地址:查找、设置和更改

...先将dhcp更改为static,然后根据您的网络为address、netmask、gateway和DNS服务器添加行。 ...

  • 发布于 2021-03-24 17:34
  • 阅读 ( 274 )

在linux中如何从命令行更改ip地址

...将“eth0”接口的默认网关设置为192.168.0.253: sudo route add default gw 192.168.0.253 eth0 要查看新设置,需要显示路由表。在提示下键入以下命令,然后按Enter键: route -n 相关:如何从Linux终端使用网络:你需要知道的11个命令 这就是...

  • 发布于 2021-04-06 21:46
  • 阅读 ( 181 )

什么是windows中(linux)bin目录的等价物?

...e placed by convention. It is included in the PATH environment variable by default for all users. As Ryan says (comments one and two), the \Windows\System32 directory on Windows is also in PATH for all Windows users (and, even if it is not, the program loader in Windows will search there anyhow). Yo...

  • 发布于 2021-04-10 04:59
  • 阅读 ( 115 )

在linux中,使用外部usb硬盘作为/home挂载是否安全?

...mid operation (neither Windows nor Linux likes that). Windows ships with a default setting which makes access a lot slower but safer, which means do not unplug it while in use. Speed will be slower than a direct connection to the SATA or SAS Bus. How much slower depends on the connection and for man...

  • 发布于 2021-04-10 06:07
  • 阅读 ( 222 )

Windows10包含一个名为“oneget”的linux风格的包管理器

...部分提供。 只需看看本文顶部的图片,就可以了解它是如何工作的。是的,你可以很容易地安装VLC或其他Windows软件!运行该命令后,OneGet将在您配置的包源中找到该包,将其下载到您的计算机,然后安装—所有这些都是自动完...

  • 发布于 2021-04-11 05:19
  • 阅读 ( 284 )

如何配置grub2引导加载程序的设置

...是在Ubuntu上运行sudoupdategrub。 您自己的GRUB设置存储在/etc/default/GRUB文件中。编辑此文件以更改GRUB2的设置。脚本也位于/etc/grub.d/目录中。例如,在Ubuntu上,这里有配置默认主题的脚本。还有一个os prober脚本,它检查系统内部硬盘...

  • 发布于 2021-04-11 06:36
  • 阅读 ( 163 )

一个linux操作系统究竟是如何“基于”另一个linux操作系统的?

...all subset of them, plus packaging their own, providing their own artwork, default settings, documentation etc. Note that there are variati*** to this “based on” thing. For instance, Debian fosters the creation of “pure blends” of itself: distributi*** which use Debian rather directly, and j...

  • 发布于 2021-04-11 15:10
  • 阅读 ( 210 )

命令行前面的文本叫什么?

...示的讨论都让你处于命令行的状态,那么请查看以下一些如何在提示下极客化生活的文章: 如何个性化Windows命令提示符 5个你可能不知道的Windows命令提示符技巧 初学者极客:如何开始使用Linux终端 使用以下8个技巧成为Linux终...

  • 发布于 2021-04-11 20:12
  • 阅读 ( 243 )
八ゑ难三灾
八ゑ难三灾

0 篇文章

相关推荐