How to Add a Second IP Address on Ubuntu (Step-by-Step)

How to Add a Second IP Address on Ubuntu (Step-by-Step)
User
7 Min Read
2025/08/29

Running a server on Ubuntu often brings up a simple question: what if I need more than one IP address on the same network card? It happens all the time maybe you’re hosting a couple of different sites, testing services on separate addresses, or just want to split traffic for better control. In this guide, I’ll walk you through adding a second IP address on Ubuntu, first with a quick one-liner that works until reboot, and then with a permanent setup that sticks.

How to add a second temporary IP

Open your Ubuntu terminal.

Run the following command to add a second IP:

sudo ifconfig eth0:0 192.168.1.2 netmask 255.255.255.0 up

Running that command tells Ubuntu to treat 192.168.1.2 as another IP bound to the same network card.

⚠️ Note: This change is temporary and will be lost after a reboot.

Permanent IP with /etc/network/interfaces (older Ubuntu)

On older Ubuntu systems, the classic way to add another IP was by editing the interfaces file. Open it with:

sudo nano /etc/network/interfaces

Scroll to the bottom and add a block like this:

auto eth0:0

iface eth0:0 inet static

address 192.168.1.2

netmask 255.255.255.0

network 192.168.1.0

Save the file, then bring the interface down and back up so the changes take effect:

sudo ifdown eth0:0 && sudo ifup eth0:0

From now on, Ubuntu will keep that second IP active even after you reboot.

Configuring multiple IP addresses in Ubuntu 18.04 and later with Netplan

If you’re running Ubuntu 18.04 or later, the system doesn’t use /etc/network/interfaces anymore — instead, it relies on Netplan.

To add another IP, edit the YAML config (the filename might vary, but you’ll usually find it under /etc/netplan/):

sudo nano /etc/netplan/01-netcfg.yaml

Inside the addresses list, simply add more than one IP. For example:

network:

  version: 2

  ethernets:

    eth0:

      dhcp4: no

      addresses:

     # Best En Web traffic IP

     – 10.56.78.201/24

     # Best En Mail server IP

     – 10.56.78.202/24

      gateway4: 192.168.1.1

      nameservers:

        addresses: [8.8.8.8, 8.8.4.4]

Save the file, then apply your changes:

sudo netplan apply

At this point, your eth0 interface will answer to both IPs. If something goes wrong, you can test first with:

sudo netplan try

which lets you confirm the config before it’s written permanently.

If the second IP still refuses to work

I’ve run into this a few times myself, and usually it comes down to something simple:

First thing I check is with ip addr show eth0. If I don’t see the new IP there, it means the system didn’t even load it.

If the IP shows up but pings don’t work, I restart networking with:

sudo systemctl restart networking

or just reboot the box if I’m being lazy.

Firewalls can be sneaky. More than once I forgot that ufw was blocking the new address. A quick look at the rules usually explains why nothing is coming through.

With Netplan, the YAML files are picky a single space in the wrong place can break it. That’s why I always run:

sudo netplan try

before committing changes.

And if you’re juggling multiple IPs in the same range, don’t assign two gateways. Ubuntu gets confused fast.

Whenever I’ve seen this fail, it’s usually not a big networking mystery just a typo or the fact that I didn’t actually apply the config. Nine out of ten times, fixing that brings the second IP up right away.

Conclusion

Honestly, once you’ve done it a couple of times, adding another IP on Ubuntu feels pretty natural. If I just need to test something quick, I’ll throw in the temporary command and forget about it. But when it’s a production box that has to survive reboots, I always go with a permanent setup in Netplan or the old interfaces file. It saves you from that “why did my IP disappear after restart?” headache.

0 out of 0 votes
Leave a Reply

Full Name*
Email*
Comment *

Calculate the value of 1 + 7 :

Save my name, email, and website in this browser for the next time I comment.
Recent Replies
Show More

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day