Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I have a network interface with multiple IP addresses bound to it can I set which IP address on the interface my server uses? It sees to be set to use the first IP address I added to it.

Info: Ubuntu on OpenVZ

share|improve this question

3 Answers 3

Various software will let you specify which interface to use. But globaly, the interface used is controlled by your routing rules.

You can view the routing rules with: netstat -nr

Are both interface in the same subnet? You can make sure your routing rules direct all the traffic to the interface you want.

share|improve this answer

The correct term is Multihome device. Your one network interface card has multiple IP address, in other words, your network interface card as 1 ethernet RJ45 jack with one ethernet cable connected to it. However, your it has 4 IP addresses. Yes, you can do that, the first IP address is the main one, the rest of them are called Aliases.

/sbin/ifconfig -a

you should see something like this:

eth1      Link encap:Ethernet  HWaddr 00:50:56:BC:30:FB  
          inet addr:10.100.8.31  Bcast:10.100.15.255  Mask:255.255.240.0
          ......
          ......
          ......
          RX bytes:84421113749 (78.6 GiB)  TX bytes:2094592237803 (1.9 TiB)

eth1:1    Link encap:Ethernet  HWaddr 00:50:56:BC:30:FB  
          inet addr:10.100.8.200  Bcast:10.100.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1:2    Link encap:Ethernet  HWaddr 00:50:56:BC:30:FB  
          inet addr:10.100.8.201  Bcast:10.100.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1:3    Link encap:Ethernet  HWaddr 00:50:56:BC:30:FB  
          inet addr:10.100.8.202  Bcast:10.100.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1:4    Link encap:Ethernet  HWaddr 00:50:56:BC:30:FB  
          inet addr:10.100.8.203  Bcast:10.100.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1 is my interface with 10.100.8.31 as my ipaddress, however, there are 4 alias ip addresses assigned to this nick and they show up as eth1:1, eth1:2 ...

They have corresponding ifcfg-eth1:x files. For example

ifcfg-eth1
-----------
DEVICE=eth1
BOOTPROTO=static
IPADDR=10.100.8.31
NETMASK=255.255.240.0
ONBOOT=yes
USERCTL=no


and ifcfg-eth1:1
-----------------
DEVICE=eth1:1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.100.8.200
NETMASK=255.255.240.0
USERCTL=no

So, when the system starts up, these scripts are loaded.

share|improve this answer

If that is Linux, then it is probably uses "weak host model" by default, therefore: In the weak host model, an IP host (either IPv4 or IPv6) can send packets on an interface that is not assigned the source IP address of the packet being sent. This is known as weak host send behavior. An IP host can also receive packets on an interface that is not assigned the destination IP address of the packet being received. This is known as weak host receive behavior.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.