Ubuntu – Can’t disable local addresses on network interfaces

20.04netplannetwork-bondingnetworkingsystemd-networkd

My server:

  • ASRock B450M/ac (RealTek 8111/8168/8411)
  • Ryzen 5 3400G
  • 64GB System Memory
  • Rosewill RC-411v3 (RealTek 8111/8168/8411)

My Computer:

  • Ryzen 7 2700X
  • 32GB System Memory
  • MSI X470 Gaming Pro Carbon (Intel I211)

I'm attempting to setup network bonding with my server in mode 6 (balance-alb) and I've gotten it to work, for the most part. I'm having an issue where one or both of the network cards will randomly get an IPv4 and/or IPv6 address. I don't think the IPv6 address matters, but when they get an IPv4 address, they break the bond and I lose all connection to the server. My current configuration is as follows;

network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0:
      link-local: [ ]
      #dhcp4: no
      #dhcp6: no
    enp4s0:
      link-local: [ ]
      #dhcp4: no
      #dhcp6: no
  bonds:
    bond0:
      addresses: [192.168.0.102/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [1.1.1.1, 1.0.0.1]
      dhcp6: no
      interfaces: [enp5s0, enp4s0]
      parameters:
        mode: balance-alb
        mii-monitor-interval: 1

I have tried both networkd and NetworkManager. I also tried netplan 0.99 and 0.100. Nothing disables local addresses with this configuration even though netplan says it should. How do I disable local addresses on these interfaces?

Edit:
Removed dhcp lines as they don't seem to do anything.
Update on some details for reproducing.
Disabling IPv6 seems to eliminate the issue of IPv4 addresses being added to either of the cards. This fix is broken again if netplan apply is ran again. However, on occasion neither of the cards will get an IP for a bit of time after running it. This allowed me to run speeds tests and prove this works, though not flawlessly. Rebooting is the best after changing the configuration, however moments after the reboot an IP gets added to one of the cards. Typically 169.254.x.x. This doesn't break everything, but balancing seems to break for the same transfer (upload or download). For example I upload and run a speedtest at the same time (both send data to the server). One of the cards will not receive any data and the other will split the two connections at 500mbit/s each. This does not seem to be an issue when running an upload and a download simultaneously.

Update: Welp, I gave in and reinstalled the operating system. I installed specifically Ubuntu 20.04.1 LTS. Got everything installed and plopped in the configuration for netplan above. It just worked, I didn't even have to enable bonding, it just enabled itself. No IPs have been added to either of the cards since I reinstalled the operating system. Although my issue is resolved, I still don't know what was adding those IPs in the first place. It seems as if another program was retroactively adding IPs. I found another post with someone mentioning this suspicion too.

Best Answer

Please see down at NOTE as extra IPs came back again. So I believe I found what was wrong and how to stop them from getting the extra IPs.

I'm writing this up as an answer because when I tried with netplan I was getting unstable connections with extra IPs appearing on my network cards.

On 20.04 LTS using kernel 5.4.0-54-generic.

Using ifupdown and setting the /etc/network/interfaces file as I dumped netplan all together.

Installed ifupdown and ifenslave

sudo apt install ifupdown ifenslave

Removed netplan:

sudo apt remove netplan.io

Next, I stopped the systemd-networkd and systemd-networkd.socket:

systemctl stop systemd-networkd.service
systemctl stop systemd-networkd.socket
systemctl disable systemd-networkd.service
systemctl disable systemd-networkd.socket

Check your /etc/modules for the following lines:

loop
lp
rtc
bonding

I also setup so I am not using predictive naming for my ethernet cards. I have heard from people saying that it can be bad, but it has always worked for me.

Added the following to the /etc/default/grub file then ran sudo update-grub and rebooted for changes to take effect.

GRUB_CMDLINE_LINUX_DEFAULT="nosplash net.ifnames=0 biosdevnames=0"

Then added my interfaces to /etc/network/interfaces with bonding setup for balance-alb:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
    iface eth0 inet manual
    bond-master bond0

auto eth1
    iface eth1 inet manual
    bond-master bond0

auto bond0
    iface bond0 inet static
    address 10.0.0.220
    netmask 255.255.255.0
    network 10.0.0.0
    broadcast 10.0.0.255
    gateway 10.0.0.1
    bond-mode balance-alb
    bond-miimon 100
    bond-slaves eth0 eth1

I also made it so my resolv.conf was no longer controlled by stub or anything else.

sudo unlink /etc/resolv.conf
echo "nameserver 10.0.0.1" | sudo tee /etc/resolv.conf

You can change your nameserver to whatever your router is or if you want to use 8.8.8.8.

You can add more nameservers with tee -a as well to the resolv.conf:

echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf

Feb. 25, 2021 Note: I recently had an update to my system and it kicked back on my cards to receiving extra IPs again. To resolve this I had to add denyinterfaces eth0 eth1 to the /etc/dhcpcd.conf file. Below is what my /etc/dhcpcd.conf file looks like. Make changes as needed for your network.

denyinterfaces eth0 eth1
interface bond0
        static ip_address=10.0.0.220/24
        static routers=10.0.0.1
        static domain_name_servers=9.9.9.9 149.112.112.112

Apply those network settings:

sudo /etc/init.d/networking restart

Checked with ifconfig and checked /proc/net/bonding/bond0

ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 10.0.0.220  netmask 255.255.255.0  broadcast 10.0.0.255
        ether bc:5f:f4:79:66:fe  txqueuelen 1000  (Ethernet)
        RX packets 85381  bytes 12752852 (12.7 MB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 125655  bytes 156764973 (156.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether bc:5f:f4:79:66:fe  txqueuelen 1000  (Ethernet)
        RX packets 76259  bytes 10724189 (10.7 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12520  bytes 4905475 (4.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether c8:3a:35:d6:ec:a0  txqueuelen 1000  (Ethernet)
        RX packets 9122  bytes 2028663 (2.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 113135  bytes 151859498 (151.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 55907  bytes 158911787 (158.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 55907  bytes 158911787 (158.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

and

cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: bc:5f:f4:79:66:fe
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: c8:3a:35:d6:ec:a0
Slave queue ID: 0
Related Question