永久删除网络接口

永久删除网络接口

我正在尝试永久删除网络接口。出于某种原因,ifconfig列出eth0eth1,尽管后者的 RX/TX 指标仍为零。

我怀疑额外的eth1条目可能会导致启动过程中的延迟

令人惊讶的是,搜索没有给出任何关于如何继续的答案。大多数帖子要么针对较旧版本的 Ubuntu 或 Debian,要么针对其他发行版(RedHat),要么没有永久效果,要么涉及添加界面,要么尝试关闭它但已启动,要么根本没有答案。但答案可能在 Google 的第三个结果页面之后的某个地方。

从桌面删除第二个条目(顶部栏上的向上和向下箭头)对也没有影响ifconfig

编辑:我的主板上确实有两块网卡。我承认这有点令人惊讶。我没有 wifi。问题仍然存在,至少出于好奇。

krakoukass@durum:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1f:d0:a3:40:d9  
          inet addr:192.168.1.66  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:d0ff:fea3:40d9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:84 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12255 (12.2 KB)  TX bytes:12241 (12.2 KB)

eth1      Link encap:Ethernet  HWaddr 00:1f:d0:a3:40:db  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

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:65536  Metric:1
          RX packets:634 errors:0 dropped:0 overruns:0 frame:0
          TX packets:634 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:64758 (64.7 KB)  TX bytes:64758 (64.7 KB)

krakoukass@durum:~$ lspci | grep -i eth
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02)
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02)

krakoukass@durum:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

krakoukas@durum:~$ systemctl -l status [email protected][email protected] - ifup for eth1
   Loaded: loaded (/lib/systemd/system/[email protected]; static; vendor preset: enabled)
   Active: active (exited) since Fri 2015-05-15 12:36:34 CEST; 14min ago
  Process: 457 ExecStart=/bin/sh -ec ifup --allow=hotplug %I; ifup --allow=auto %I;      if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi (code=exited, status=0/SUCCESS)
 Main PID: 457 (code=exited, status=0/SUCCESS)

May 15 12:36:34 durum systemd[1]: Started ifup for eth1.
May 15 12:36:34 durum systemd[1]: Starting ifup for eth1...
May 15 12:36:34 durum sh[457]: Unknown interface eth1

krakoukas@durum:~$ systemctl -l status [email protected][email protected] - ifup for eth0
   Loaded: loaded (/lib/systemd/system/[email protected]; static; vendor preset: enabled)
   Active: active (exited) since Fri 2015-05-15 12:36:34 CEST; 15min ago
  Process: 458 ExecStart=/bin/sh -ec ifup --allow=hotplug %I; ifup --allow=auto %I;      if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi (code=exited, status=0/SUCCESS)
 Main PID: 458 (code=exited, status=0/SUCCESS)

May 15 12:36:34 durum systemd[1]: Started ifup for eth0.
May 15 12:36:34 durum systemd[1]: Starting ifup for eth0...
May 15 12:36:34 durum sh[458]: Unknown interface eth0

提前感谢您的帮助。

答案1

要永久删除我认为你应该使用这个

sudo nmcli connection show

结果如下:

NAME                UUID                                  TYPE       DEVICE 
front               2cf067c7-e0ad-4072-b60f-60a7733b5c27  wifi       wlp1s0 
wg0                 ab0b9039-c4b1-48af-b30c-adcbea993643  wireguard  wg0    
WebSolutions        07749022-afa7-467e-a625-a87de9875ab7  vpn        --     
BlackHome           061a7dbf-5d7d-4992-a78d-015b3d93f5af  wifi       --    

然后通过UUID删除

sudo nmcli connection delete ab0b9039-c4b1-48af-b30c-adcbea993643

答案2

/etc/network/interfaces在终端中打开文件

sudo nano /etc/network/interfaces

添加此行:

iface eth1 inet manual

保存文件并运行

sudo service network-manager restart

或者

sudo systemctl restart network-manager.service

(注意:在较新的 Ubuntu 上,该network-manager服务已重命名为NetworkManager服务)

来源

相关内容