8

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!

2 Answers 2

2

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.

0

I am using a setup you want but on CentOS. I believe you can figure it out how to translate it to ubuntu config if I just show you how it works in CentOS. My setup is like this:

ifcfg-eth4

DEVICE=eth4
BOOTPROTO=none
HWADDR=00:0F:FE:E4:A4:CF
ONBOOT=yes
HOTPLUG=no
SLAVE=yes
MASTER=bond2

ifcfg-bond2

DEVICE=bond2
BOOTPROTO=none
IPADDR=192.168.20.1
NETMASK=255.255.0.0
ONBOOT=yes
TYPE=bonding
MASTER=yes
BONDING_OPTS="miimon=100 mode=1" 

ifcfg-bond2:1

DEVICE=bond2:1
BOOTPROTO=none
IPADDR=192.168.41.1
NETMASK=255.255.0.0
ONBOOT=yes
TYPE=bonding
MASTER=yes
BONDING_OPTS="miimon=100 mode=1" 

So I would try it that way in your case:

# 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

auto bond0:1
iface bond0 inet static
address 192.168.1.300
gateway 192.168.1.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

Try it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.