首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除从/etc/网络/接口(ifupdown)创建的连接接口?

删除从/etc/网络/接口(ifupdown)创建的连接接口?
EN

Unix & Linux用户
提问于 2019-12-05 14:08:09
回答 2查看 35.4K关注 0票数 5

我尝试将两个接口连接成一个,创建了bond0,结果发现它不能令人满意。然后,我恢复对/etc/network/interfaces所做的所有更改并运行systemctl restart networking.service,但是键接口仍然存在(显示在ifconfigip link命令中),我不得不运行ip link set bond0 downifconfig bond0 down来强制将其踢出。如何在不重新启动服务器的情况下完全删除此接口?

我在演Debian Buster。该文件最初是这样的:

代码语言:javascript
复制
auto eno1
iface eno1 inet static
    # regular network settings like address, netmask, gateway etc.
auto eno2
iface eno2 inet static
    # regular network settings like address, netmask, gateway etc.

我将两个接口转换成一个键,将其转换为:

代码语言:javascript
复制
auto eno1
iface eno1 inet manual
    bond-master bond0
auto eno2
iface eno2 inet manual
    bond-master bond0

auto bond0
iface bond0 inet static
    # regular network settings like address, netmask, gateway etc.
EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2019-12-05 17:32:50

与大多数其他接口一样,管理键接口的现代命令是ip link,这里是随同系统,用于可能没有通过(rt)netlink直接处理的少数事情。在这个案例中:

代码语言:javascript
复制
ip link delete dev bond0

任何仍然被奴役的接口,当移除键时都会被分离,所以没有必要先分离它(使用ip link set DEVICE nomaster)。

要这样做的替代方案sysfs方法是:

代码语言:javascript
复制
echo -bond0 > /sys/class/net/bonding_masters
票数 3
EN

Unix & Linux用户

发布于 2019-12-05 16:38:37

键合接口由ifenslave(8)命令行实用程序管理。

下面是该手册的摘录:

代码语言:javascript
复制
NAME
     ifenslave -- Attach and detach slave network devices to a bonding device.

SYNOPSIS
     ifenslave [-acdfhuvV] [--all-interfaces] [--change-active] [--detach] [--force] [--help] [--usage] [--verbose] [--version] master slave ...

DESCRIPTION
     ifenslave is a tool to attach and detach slave network devices to a bonding device.  A bonding device will act like a normal Ethernet network device to the kernel,
     but will send out the packets via the slave devices using a simple round-robin scheduler.  This allows for simple load-balancing, identical to "channel bonding" or
     "trunking" techniques used in switches.

     The kernel must have support for bonding devices for ifenslave to be useful.

OPTIONS
     -a, --all-interfaces
             Show information about all interfaces.

     -c, --change-active
             Change active slave.

     -d, --detach
             Removes slave interfaces from the bonding device.

免责声明:我没有测试以下

要完全删除bond0,我会:

  • ifconfig bond0 down
  • ifenslave -d bond0 eno1
  • ifenslave -d bond0 eno2
  • ̀rmmod键

这应该是值得的。

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/555745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档