Servers sometimes need more than one IP address: separate IPs for different SSL sites on old clients, a dedicated IP for a mail server’s reputation, services that must listen on their own address, or outbound traffic from a specific IP. Once your provider has assigned the additional IPs to your server, you configure them on the network interface. Here’s how on each common setup.
First, get the addresses from your provider. Adding an IP that isn’t routed to your server doesn’t work, and can disrupt other customers. On VPS.DO, additional IPv4 addresses for multi-IP VPS use are assigned to your service, and you configure them inside the OS. Note the netmask and gateway details your provider gives you.
Check the current configuration
ip -br addr
ip route
Find the interface name (eth0, ens3, enp1s0…) and the existing primary address. See ip command.
Temporary: ip addr (lost at reboot)
Useful for testing:
sudo ip addr add 203.0.113.21/32 dev eth0
ip addr show eth0
ping -c 3 -I 203.0.113.21 1.1.1.1 # test outbound from the new IP
Remove it again:
sudo ip addr del 203.0.113.21/32 dev eth0
Use the prefix length your provider specifies: /32 for a single routed IP, or the subnet’s prefix (e.g. /24 or /29) if the IPs are part of an on-link subnet.
Ubuntu: Netplan
Edit the existing file in /etc/netplan/ (e.g. 50-cloud-init.yaml or 01-netcfg.yaml):
network:
version: 2
ethernets:
eth0:
addresses:
- 203.0.113.10/24 # primary
- 203.0.113.21/32 # secondary
- 203.0.113.22/32
routes:
- to: default
via: 203.0.113.1
nameservers:
addresses: [1.1.1.1, 9.9.9.9]
Apply it safely: netplan try rolls back automatically if you lose connectivity and don’t confirm:
sudo netplan try
sudo netplan apply
If the file is generated by cloud-init, stop cloud-init from overwriting your changes. Create /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with network: {config: disabled}. See netplan and cloud-init.
Debian: ifupdown (/etc/network/interfaces)
auto eth0
iface eth0 inet static
address 203.0.113.10/24
gateway 203.0.113.1
# secondary addresses
iface eth0 inet static
address 203.0.113.21/32
iface eth0 inet static
address 203.0.113.22/32
Apply it carefully. Restarting networking over SSH can cut your connection:
sudo ifup eth0 # or reboot during a maintenance window
Keep the VNC console open in case something goes wrong. See Linux rescue mode.
RHEL family: NetworkManager (nmcli)
nmcli connection show
sudo nmcli connection modify "System eth0" +ipv4.addresses 203.0.113.21/32
sudo nmcli connection modify "System eth0" +ipv4.addresses 203.0.113.22/32
sudo nmcli connection up "System eth0"
Use the extra IPs
Nginx: bind a site to a specific IP:
server {
listen 203.0.113.21:443 ssl;
server_name shop.example.com;
…
}
With SNI, every modern client can serve many HTTPS sites from one IP. Dedicated IPs mainly matter for specific requirements (legacy clients, IP-based allow-lists, separation). See Nginx server blocks.
Mail server: send from a dedicated IP with its own PTR record:
# /etc/postfix/main.cf
smtp_bind_address = 203.0.113.22
Set reverse DNS for that IP to match the mail hostname. See PTR records.
Outbound traffic from a specific IP:
curl --interface 203.0.113.21 https://ifconfig.me
Applications often have a “bind address” or “source address” option. For system-wide changes, set src on the default route (ip route change default via 203.0.113.1 src 203.0.113.21).
Docker: publish a container port on one IP only: -p 203.0.113.21:443:443. See Docker networking.
Firewall
UFW rules apply to all addresses unless you specify one:
sudo ufw allow to 203.0.113.21 port 443 proto tcp
Verify from outside
ping 203.0.113.21
nc -zv 203.0.113.21 443
If the IP answers locally but not from outside, check with your provider that it’s routed to your server, and that the prefix length and gateway are correct.
Quick reference
| Task | Command / file |
|---|---|
| Show addresses | ip -br addr |
| Add temporarily | ip addr add IP/32 dev eth0 |
| Ubuntu (persistent) | /etc/netplan/*.yaml + netplan try |
| Debian (persistent) | /etc/network/interfaces |
| RHEL (persistent) | nmcli connection modify … +ipv4.addresses |
| Outbound from IP | curl --interface IP … |
Related: multi-IP VPS and IPv4 vs IPv6.