How to Configure Dual IPs on a Single NIC in Ubuntu 12.04

Sometimes a server only has one network interface card. If you need it to serve both internal and external traffic, you’ll need to configure dual IPs. On Ubuntu 12.04, simply edit /etc/network/interfaces and add the following at the end:

auto eth0:0iface eth0:0 inet staticaddress 192.168.2.230netmask 255.255.255.0gateway 192.168.2.1

The key part is the eth0:0 notation. Here, eth0 represents the machine’s first network card, and the trailing 0 indicates a virtual sub-interface. To add yet another IP, you would use eth0:1, and so on. Adjust the address, netmask, and gateway parameters as needed.

Then restart the networking service:

sudo /etc/init.d/networking restart

Use ifconfig to check eth0:0:

ifconfig eth0:0
Configure Dual IPs on a Single NIC

Configure Dual IPs on a Single NIC

Leave a Comment

Your email address will not be published.