Skip to main content

Configure Additional IP Addresses

If your server needs to be reachable on more than one IPv4 address, you can add additional addresses to your existing network interface.

Prerequisites

Netplan

Open /etc/netplan/55-interfaces.yaml in your preferred editor:

vi /etc/netplan/55-interfaces.yaml

And add the additional IP address under addresses:

bonds:
bond0:
addresses:
- 198.51.100.10/24
- 198.51.100.11/24

A complete Netplan configuration could look like this:

network:
version: 2
ethernets:
eno1:
dhcp4: false
dhcp6: false
accept-ra: false
eno2:
dhcp4: false
dhcp6: false
accept-ra: false
bonds:
bond0:
addresses:
- 198.51.100.10/24
- 198.51.100.11/24
nameservers:
addresses:
- 217.150.241.5
- 217.150.242.21
- 178.209.45.7
search:
- nine.ch
macaddress: 1f:2f:3f:4f:5f:6f # MAC address of the first interface (eno1)
interfaces:
- eno1
- eno2
parameters:
mode: "802.3ad"
mii-monitor-interval: "100"
lacp-rate: "fast"
transmit-hash-policy: "layer3+4"
routes:
- to: 0.0.0.0/0
via: 198.51.100.1

Before applying the Netplan configuration, test it to ensure there are no syntax errors or network issues:

netplan try

If the test was successful and the configuration hasn't been applied yet using netplan try, apply it now:

netplan apply

And verify with:

ip -4 addr show bond0

For more information, see: man netplan

ifupdown (legacy)
tip

Please use Netplan if possible. This is provided for completeness only.

Open /etc/network/interfaces in your preferred editor:

vi /etc/network/interfaces

Add the additional IP address(es):

auto bond0
iface bond0 inet static
hwaddress ether 1f:2f:3f:4f:5f:6f
address 198.51.100.10
netmask 255.255.255.0
gateway 198.51.100.1
bond_slaves eno1 eno2
bond_primary eno1
bond_mode 4
bond_miimon 100
bond_xmit_hash_policy layer3+4
bond_lacp_rate 1
# Add secondary IP address
up ip addr add 198.51.100.11/24 dev bond0 || true

And restart the network:

systemctl restart networking

For more information, see: man interfaces