Add an IP Address Range to a Server: Ubuntu 26.04, Debian 13, AlmaLinux 9
Assign a block of additional IPv4 addresses to one network interface with Netplan, NetworkManager or ifupdown, make it persistent and verify it.
When your provider assigns you an extra block of IPv4 addresses, each address has to be configured on the server before it answers. This guide adds a whole range to one interface, persistently, on Ubuntu 26.04 LTS (Netplan; 24.04 works the same way), on AlmaLinux 9, Rocky Linux 9 and CentOS Stream 9 (NetworkManager), and on Debian 13 (ifupdown; the same on Debian 12). None of these tools has a start-to-end range syntax, so a short shell loop generates the list.
The examples use the interface eth0, the existing primary address 203.0.113.5 and the additional block 198.51.100.16/28, which is the 16 addresses 198.51.100.16 to 198.51.100.31. Replace all three with your own values; find your interface name with ip -brief link.
Before you start
Find out how the range is delivered
The correct prefix length depends on how the provider hands you the block, so check the allocation details in your hosting control panel:
- Routed block: the provider routes the whole block to your primary address. Every address in the block is usable, and you add each one with a
/32prefix. The examples below assume this case. - On-link subnet: the addresses live in a shared network with its own gateway. Use the prefix the provider gives you (for example
/24) and do not assign the network address, the broadcast address or the gateway.
You do not add another default gateway for extra addresses on the same interface. Some providers also require each address to be attached to the server, or bound to a MAC address, in their control panel before traffic reaches you.
Keep a way back in
A mistake in network configuration can cut off SSH. Have your provider's web console open, or at least a second SSH session, before applying changes.
Test with one address
An address added with ip takes effect immediately and disappears on reboot, which makes it a safe test:
sudo ip addr add 198.51.100.16/32 dev eth0Ping it from another machine. If it does not answer, the problem is on the provider side (routing or address attachment), and persistent configuration will not help yet. Remove the test address before you continue so it does not collide with the permanent configuration:
sudo ip addr del 198.51.100.16/32 dev eth0Ubuntu 26.04 and 24.04: Netplan
Netplan reads every YAML file in /etc/netplan and merges them, so put the extra addresses in a file of their own and leave the existing one (often 50-cloud-init.yaml) untouched. Each address is a list entry in CIDR notation. The interface key in the new file must be the same key the existing file uses under ethernets: (check with sudo netplan get), otherwise Netplan treats it as a different device. Generate the file with a loop:
{
printf 'network:\n version: 2\n ethernets:\n eth0:\n addresses:\n'
for i in $(seq 16 31); do
printf ' - 198.51.100.%s/32\n' "$i"
done
} | sudo tee /etc/netplan/60-extra-ips.yaml
sudo chmod 600 /etc/netplan/60-extra-ips.yamlThe result looks like this, with one line per address:
network:
version: 2
ethernets:
eth0:
addresses:
- 198.51.100.16/32
- 198.51.100.17/32
- 198.51.100.18/32Apply it with netplan try, which rolls the change back automatically unless you confirm it within the timeout:
sudo netplan tryPress Enter to keep the configuration. Addresses listed under addresses are added to whatever the interface already receives through DHCP, so this works for both static and DHCP-configured primary addresses.
AlmaLinux 9, Rocky Linux 9 and CentOS Stream 9: nmcli
CentOS 6, 7 and 8 are end-of-life. Older tutorials for them use range files such as ifcfg-eth0-range0 with IPADDR_START and IPADDR_END; those were a feature of the legacy network scripts, which are no longer part of the 9 releases. NetworkManager manages the interfaces instead, and its ipv4.addresses property takes a list of individual addresses with prefix lengths.
Look up the name of the connection profile bound to the interface, then append each address to it:
CON="$(nmcli -g GENERAL.CONNECTION device show eth0)"
echo "$CON"
for i in $(seq 16 31); do
sudo nmcli connection modify "$CON" +ipv4.addresses "198.51.100.$i/32"
doneThe + prefix appends to the existing list instead of replacing it. Re-activate the profile to apply the change:
sudo nmcli connection up "$CON"Check what is stored in the profile with:
nmcli -g ipv4.addresses connection show "$CON"To remove an address later, use the - prefix: sudo nmcli connection modify "$CON" -ipv4.addresses "198.51.100.31/32", followed by nmcli connection up again.
Debian 13 and 12: ifupdown
A standard Debian server installation configures the network in /etc/network/interfaces. Check that this applies to your system first: if the file has no entry for your interface, the machine is probably managed by systemd-networkd, Netplan or NetworkManager (common on cloud images), and you should use that tool instead.
ifupdown accepts several iface stanzas for the same interface, each adding one address. A default installation includes the directory /etc/network/interfaces.d from the main file; confirm it, then generate the stanzas into a separate file there:
grep source /etc/network/interfacesfor i in $(seq 16 31); do
printf 'iface eth0 inet static\n address 198.51.100.%s/32\n\n' "$i"
done | sudo tee /etc/network/interfaces.d/extra-ipsThe file now contains blocks like this:
iface eth0 inet static
address 198.51.100.16/32
iface eth0 inet static
address 198.51.100.17/32The prefix length is written as part of address; the separate netmask option is deprecated. The new stanzas are read the next time the interface is brought up. The least risky way to apply them on a remote server is a reboot:
sudo systemctl rebootVerify
List the addresses on the interface and count them:
ip -4 addr show dev eth0
ip -4 -o addr show dev eth0 | wc -lThe count should be your primary address plus the size of the range (17 in the example). Then ping a few of the new addresses from a machine outside your network, and test outgoing traffic from one of them:
ping -c 3 -I 198.51.100.20 203.0.113.1Reboot once and repeat the check to confirm that the configuration is persistent.
Using the addresses
Adding an address only makes the server answer on it. Services decide for themselves which addresses they listen on: a daemon bound to 0.0.0.0 accepts connections on all of them, while one bound to a specific address needs its configuration changed. Outgoing connections keep using the primary address unless the application is told to bind to another one, or you add source-address rules.
Review your firewall as well. Rules written for the primary address do not automatically cover the new ones.
Frequently asked questions
Why is there no range syntax like the old IPADDR_START and IPADDR_END?
Netplan, NetworkManager and ifupdown all model addresses as individual entries with a prefix length. A loop that writes those entries does the same job and leaves a configuration in which every address is visible and can be removed on its own.
Should I use /32 or the subnet's real prefix?
Use /32 when the block is routed to your server. Use the real prefix only when the addresses are on a shared network segment with their own gateway; with a wider prefix the kernel also adds a route that treats the whole subnet as directly reachable on that interface, which is wrong for a routed block.
How many addresses can one interface carry?
Linux has no practical limit for this purpose; thousands of addresses on one interface work. For very large blocks that only need to terminate traffic locally, routing the prefix to the loopback interface or using the kernel's ip_nonlocal_bind setting is easier to manage than listing every address.
Do I need alias interfaces such as eth0:0?
No. Alias interfaces are a leftover from the old ifconfig tooling. Modern kernels attach any number of addresses directly to an interface, and ip addr shows them all. Netplan can attach a label to an address if an old script still expects an alias name.