Two IPs on one NIC ( network card )

I'm not quite sure exactly what you're trying to accomplish. I am assuming that your question could be re-titled "How to set up two IPs on a single network interface."

Each network interface on your machine is given an identifier. Typically, you start with eth0 and work your way up (eth1, eth2, eth3). These are all physically different network cards.

You can also have virtual cards on top of each of your physical cards. This is how you would set up multiple IPs on the same NIC.

To set this up, you can use the following example, changing the addresses to suit your needs (/etc/network/interfaces):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback


# The primary network interface
auto eth0 eth0:0
allow-hotplug eth0 eth0:0

#eth0
iface eth0 inet static
address 123.123.123.123
netmask 255.255.255.0
gateway 123.123.123.1

#eth0:0 (LAN)
iface eth0:0 inet static
address 212.212.212.212
netmask 255.255.128.0
gateway 212.212.212.1

The tricky part could be the netmask. Try 255.255.255.0 if you aren't sure.


If you set a secondary IP for eth0, it should be set to eth0:0:

sudo ip addr add 188.40.90.88 dev eth0:0

On Ubuntu you could try this:

If you have two IP adresses configured on your server, to see them you could run a simple ifconfig:

# ifconfig

eth1  Link encap:Ethernet  HWaddr 00:aB:cD:eF:Gh:Ij  
      inet addr:X.X.X.X  Bcast:X.X.X.X  Mask:255.255.255.248 # IP address ONE
      inet6 addr: fe80::230:48ff:fe34:1c17/64 Scope:Link


eth1:0 Link encap:Ethernet  HWaddr 00:aB:cD:eF:Gh:Ij  
      inet addr:X.X.X.X  Bcast:X.X.X.X  Mask:255.255.255.255 # IP address TWO
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

If you want to configure your second IP address in the same NIC you must specify your NIC interface & create a virtual IP:

# ifconfig eth1:0 X.X.X.X netmask 255.255.255.255 # Setting up IP address TWO

If you want to reach a specific address through your virtual or secondary IP, you could make a route.

# ip route add <target> via <network IP> dev <NIC interface [eth1]> [SECOND IP]