Linux VPS

Add an additional IPv4 address to a Linux VPS

Configure a second or extra IPv4 address on a Linux VPS with Netplan on Ubuntu, NetworkManager on AlmaLinux/Rocky or ifupdown on Debian, test it and bind services to it.

IntermediateLinux VPS2 min read

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. eth0 or ens3).

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 show
nmcli con mod "System eth0" +ipv4.addresses 203.0.113.25/24
nmcli 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 eth0

Then systemctl restart networking from the console.

Test the new address

  1. ip -4 addr show eth0 lists both IPs.
  2. From another computer: ping 203.0.113.25.
  3. 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_address and 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.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.