Extra IPs are useful for separate SSL sites on old clients, mail servers with their own reputation, or running several services on the same port. Your provider routes the address to your VPS, but you usually have to configure it inside the OS. This guide shows how to add an additional IPv4 address on the common distributions.
Before you start
- The new IP, its netmask (often the same as your main IP's) and gateway from your provider. Some providers route single IPs as
/32. - Console access in case networking breaks; see VNC console.
- Check your interface name with
ip a(e.g.eth0orens3).
Ubuntu with Netplan
Edit your file in /etc/netplan/ and add the address to the list:
network:
version: 2
ethernets:
eth0:
addresses:
- 203.0.113.10/24
- 203.0.113.25/24
routes:
- to: default
via: 203.0.113.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]Apply safely with sudo netplan try. If your VPS uses DHCP for the main IP, keep dhcp4: true and just add the extra address. Netplan details: static IP with Netplan.
AlmaLinux / Rocky with NetworkManager
nmcli con shownmcli con mod "System eth0" +ipv4.addresses 203.0.113.25/24nmcli con up "System eth0"Use the connection name shown by the first command.
Debian with ifupdown
In /etc/network/interfaces under your interface add:
up ip addr add 203.0.113.25/24 dev eth0
down ip addr del 203.0.113.25/24 dev eth0Then systemctl restart networking from the console.
Test the new address
ip -4 addr show eth0lists both IPs.- From another computer:
ping 203.0.113.25. - Test outgoing traffic from it:
curl --interface 203.0.113.25 https://ifconfig.me.
Use the new IP
- Nginx:
listen 203.0.113.25:443 ssl;in the server block. - Mail: bind Postfix with
smtp_bind_addressand set reverse DNS for that IP (in your VPS panel, see reverse DNS setup). - Open required ports in your firewall.
Troubleshooting
- IP does not respond: the provider has not routed it to your VPS yet, or the netmask is wrong.
- Lost all connectivity: a YAML indentation error; fix from console and use
netplan try. - Outgoing mail uses the wrong IP: set the bind address in the mail server.
Frequently asked questions
Do I need a separate gateway for the extra IP?
Usually not if it is in the same subnet. Different subnets may need their own route; follow the provider's details.
Is IPv6 configured the same way?
Similarly; see IPv6 setup on a VPS.
Does each website need its own IP?
No. With SNI, many HTTPS sites share one IP.
