Multiple IP addresses with bonded interfaces

11,896

As I had this issue myself and there is little information on it anywhere, so here is the "correct" solution for the /etc/network/interfaces file:

auto bond0
iface bond0 inet static
    address 192.168.0.5
    netmask 255.255.255.0
    gateway 192.168.0.1
    bond-mode 802.3ad
    bond-miimon 100
    bond-updelay 200
    bond-downdelay 200
    bond-lacp-rate 1
    bond-slaves eth0 eth1

auto bond0:1
iface bond0:1 inet static
    address 192.168.10.160
    netmask 255.255.255.0

It works almost the same as with regular interfaces like eth0, but you must not repeat the bond configuration - that should only be in the bond0 configuration. You can then add as many additional IP addresses as needed like this, as bond0:2, bond0:3, etc.

If you also want to add IPv6 addresses, it is a little different again, as you need to add this (as an example):

iface bond0 inet6 static
    address 2eee:354:3a3::745
    netmask 64
    gateway 2eee:354:3a3::1

IPv6 does not need bond0:1 or similar workarounds - just use bond0 for every address. It uses the bond settings from the IPv4 address, like a second IPv4 address. And you do not need to repeat the gateway part for additional IPv6 addresses, just use address and netmask for the second IPv6 address.

After you changed the interfaces file, you should execute the following commands to fully restart networking and load these changes:

ip address flush eth0
ip address flush eth1
systemctl restart networking

This removes all IP addresses from eth0 and eth1 and then restarts networking with the new configuration. Make sure you are logged in locally to the machine, as you need to completely turn of networking before restarting it, so all connections will be lost.

Share:
11,896

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I have a server with two ethernet ports and I have bonded them together with the following config in /etc/network/interfaces:

    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    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 192.168.0.300
    gateway 192.168.0.1
    netmask 255.255.255.0
    dns-nameservers 8.8.8.8 8.8.4.4
    bond-mode balance-rr
    bond-miimon 100
    bond-slaves eth0 eth1
    

    So currently, all connections are routed through bond0. I need another interface such as bond1 that can operate on a separate IP address such as 192.168.0.301.

    I know that in order to achieve this with just the eth0 interface, I need to append:

    auto eth0:0
    iface eth0:0 inet static
    (and so on)
    

    but how would I go about this with a network bond? Something along the lines of bond0:0 and bond0:1 maybe? Or bond0 and bond1 but create 4 total network interfaces such as: eth0:0 eth1:0 and eth0:1 and eth1:1 and use them as the respective slaves for the two separate bonds? Kinda confusing, but any help would be appreciated!