在 Debian 上禁用网络适配器 eth0

Tho*_*hom 11 networking debian

曾几何时,我使用 ifdown eth0 关闭网络适配器。自从我使用 Ubuntu/Debian 以来,我已经能够让它工作多年了。

我明白了:

$ sudo ifdown eth0
ifdown: interface eth0 not configured
Run Code Online (Sandbox Code Playgroud)

如果我运行 ifconfig,我会得到:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:192.168.20.50  Bcast:192.168.21.255  Mask:255.255.254.0
          inet6 addr: fe80::6e3b:e5ff:fe36:2ee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1205280 errors:0 dropped:502 overruns:0 frame:0
          TX packets:34930 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:165685286 (165.6 MB)  TX bytes:5754120 (5.7 MB)
          Interrupt:20 Memory:f7f00000-f7f20000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:9146 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9146 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:734342 (734.3 KB)  TX bytes:734342 (734.3 KB)
Run Code Online (Sandbox Code Playgroud)

我在谷歌上搜索了如何做到这一点,我能找到的一切都说运行 ifdown eth0。如何在 Debian/Ubuntu 机器上停止网络适配器?

Tim*_*ann 14

我在 Debian 上面临同样的问题。我不知道确切的原因,但是,它对sudo ifconfig eth0 down我有用。

编辑:感谢@kostix 的注释。由于我使用它来暂时关闭界面,因此我没有详细关注该问题。如果你想永久关闭它, ifdown 是要走的路。为此,您需要将行添加eth0=eth0/run/network/ifstate和行auto eth0iface eth0 inet dhcp/etc/network/interfaces


Nic*_*net 14

如果ifconfig在您的发行版上不可用,则意味着它已被ip命令替换。在这种情况下,解决方案是ip link set eth0 down