Delete a bond interface created from /etc/network/interfaces (ifupdown)?
Solution 1
The modern command to manage bond interfaces is, like for most other interfaces, ip link
, here along with sysfs for the possible few things not handled directly through (rt)netlink. In this case:
ip link delete dev bond0
Any interface still enslaved when removing the bond will be detached, so there's no need to detach it first (using ip link set DEVICE nomaster
).
An alternate sysfs method to do the same is:
echo -bond0 > /sys/class/net/bonding_masters
Solution 2
bonding interfaces are managed by ifenslave(8)
command line utility.
Below is an extract of the manpage:
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.
DISCLAIMER: i didn't tested the following
To totally remove bond0
, i would:
ifconfig bond0 down
ifenslave -d bond0 eno1
ifenslave -d bond0 eno2
- ̀ rmmod bonding`
It should be enought.
iBug
My profile on Meta: https://meta.stackexchange.com/users/350567
Updated on September 18, 2022Comments
-
iBug almost 2 years
I made an attempt bonding two interfaces into one, created
bond0
, and found it unsatisfactory. I then reverted all changes made to/etc/network/interfaces
and ransystemctl restart networking.service
, but the bond interface still existed (shows up inifconfig
andip link
commands) and I had to runip link set bond0 down
orifconfig bond0 down
to force kick it out. How do I completely remove this interface without rebooting the server?I'm on Debian Buster. The file was originally like this:
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.
I turned both interfaces into one bond by changing it into this:
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.
-
iBug over 4 yearsAh, yes. This
iproute2
is what I'm using from day to day.