Score:0

Network bonding: slave NICs still get DHCP

km flag

I'm setting up bonding of two 1 GB Ethernet NICs on Ubuntu Server 20.04 LTS in mode 0 (balanced-rr).

The bond is working in that it comes up at the assigned IP address and I can SSH into it at this address. However, each of the bonded slave NICs still get a DHCP address assigned.

How can I set this up so only the bond has an IP address?

Here's how I set it up:

sudo apt-get install ifenslave
sudo modprobe bonding
Edited /etc/modules to add "bonding"

Finally, edited /etc/network/interfaces to contain the following: (Note, it was blank before I edited it)

# bond0 is the bonded NIC, can be used like a normal NIC
auto bond0
iface bond0 inet static
  address 10.16.0.91
  gateway 10.16.0.1
  netmask 255.255.0.0

  #mode 0 is balanced-rr
  bond-mode 0
  bond-miimon 100
  bond-slaves enp1s0 enp2s0

# enp1s0 connected to bond0
auto enp1s0
iface enp1s0 inet manual
  bond-master bond0

# enp2s0 connected to bond0
auto enp2s0
iface enp2s0 inet manual
 bond-master bond0

After rebooting, when I do "ifconfig" it gives the following (and I can use all 3 IPs)

bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 10.16.0.91  netmask 255.255.0.0  broadcast 10.16.255.255
        inet6 fe80::203:2dff:fe41:edae  prefixlen 64  scopeid 0x20<link>
        ether 00:03:2d:41:ed:ae  txqueuelen 1000  (Ethernet)
        RX packets 356  bytes 29976 (29.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 110  bytes 16969 (16.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp1s0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        inet 10.16.100.143  netmask 255.255.0.0  broadcast 10.16.255.255
        ether 00:03:2d:41:ed:ae  txqueuelen 1000  (Ethernet)
        RX packets 252  bytes 23651 (23.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 76  bytes 8779 (8.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x91300000-913fffff

enp2s0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        inet 10.16.100.142  netmask 255.255.0.0  broadcast 10.16.255.255
        ether 00:03:2d:41:ed:ae  txqueuelen 1000  (Ethernet)
        RX packets 240  bytes 19975 (19.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 75  bytes 12250 (12.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x91100000-911fffff

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 85  bytes 6400 (6.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 85  bytes 6400 (6.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

How do I prevent the slave interfaces from getting their own DHCP address?

wkwave avatar
km flag
Thanks for the suggestion, @Terrance. Unfortunately, it doesn't - the system doesn't have dhcpcd (there is not a /etc/dhcpcd.conf file.) I looked to see if there is a way to do something similar using /etc/dhcp/dhclient.conf but it didn't appear so.
Terrance avatar
id flag
Maybe look at the answer here: https://askubuntu.com/questions/1293208/cant-disable-local-addresses-on-network-interfaces/1293486#1293486 Possible that netplan.io is still there causing some issues?
wkwave avatar
km flag
I'm not using netplan. (The only updates to the networking after the Ubuntu server install are those above.) In that linked question, the Answer "Feb. 25, 2021 Note:" it seems the final solution was for DHCPCD, editing the /etc/dhcpcd.conf file again.
Terrance avatar
id flag
I wrote that answer, but I also removed Netplan.io from the system to stop conflicting with ifupdown. I wasn't using netplan either, but it was there causing issues as well.
wkwave avatar
km flag
I see. Removing netplan.io did indeed fix the issue! It also seems to have removed an irritating wait on network configuration that was causing the boot to take a lot longer. @Terrance you sir are a gentleman and a scholar! Thank you.
Terrance avatar
id flag
Let me write that up here.
Score:0
id flag

Since you are going to be using ifupdown for controlling your network cards, the application of netplan.io is no longer needed. It will conflict with ifupdown causing issues of extra IP addresses, etc.

sudo apt remove netplan.io

Hope this helps!

cn flag
that wants to remove ubuntu-minimal as well, which sounds important, can netplan.io be removed in 22.04?
Terrance avatar
id flag
@teknopaul I don't have it installed on my 22.04, but I don't remember it asking to remove ubuntu-minimal. It only removed the netplan.io for me. Then again, when I upgraded to 22.04 I can't remember if netplan.io was even installed.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.