-1

Is it possible to configure in the same NIC a VIP and a private IP (different) and both be enabled/accesible?
If yes, is there a guarantee that the communication path for these 2 IPs will be exactly the same?
Update: If this is possible, if I e.g. do a ping (or traceroute) from a specific machine will I always have the same route for both these 2 IPs?

user76678
  • 349
  • 3
  • 5
  • 16
  • what do you mean by vip? An IP is an IP. you can assign as many as you like. The path selected depends on the routing table. – Zoredache Dec 12 '12 at 21:40
  • Virtual IP I mean.So I can have both a public virtual IP and a public IP?Also the routing table could be different even if the MAC destined is the same? – user76678 Dec 12 '12 at 21:43
  • You're question isn't very clear and I'm not sure how you imagine it is that you'd assign a "VIP" to the NIC, but certain load balancing technologies (such as NLB in Windows) create a virtual ip address and bind it to the NIC of the load balanced members. Is this what you're referring to? – joeqwerty Dec 12 '12 at 21:47
  • @joeqwerty:Correct – user76678 Dec 12 '12 at 21:48
  • @joeqwerty:Updated OP – user76678 Dec 12 '12 at 22:08
  • @Zoredache:Updated OP – user76678 Dec 12 '12 at 22:11
  • @user76678 - I would think that you would always have the same route for both ip addresses for communication between a specific host and the server, using either ip address. – joeqwerty Dec 12 '12 at 22:17
  • If the IPs are on different subnets (and they are, since you say one is public and one is private), then the routes, by definition, will always be different. – mfinni Dec 12 '12 at 23:57

2 Answers2

2

You can have as many virtual IPs on the same physical device. On Linux you can create virtual interfaces for an IP (mostly) like this:

ifconfig eth0:0 10.10.10.42 netmask 255.255.255.0 up

or via /etc/network/interfaces

The route for every IP can be determined independently. Every IP can have a different default route. But you can ping in and out from every of this IPs

Christopher Perrin
  • 4,811
  • 19
  • 33
2

Having multiple IPs on a NIC is not an issue at all. You can use regular tools like ip addr add 1.2.3.4/24 dev eth0 and a configuration file would be distribution dependent.

The switch where your nic is connected will broadcast a "who has IP a.b.c.d" and your NIC will respond if it is one of the IPs it has. Receiving packets is not an issue.

The outgoing packets, however, are a different story. In response to a ping, the outgoing packet's source IP will be determined from the routing table (ip route show). This will be most likely based on the destination IP, and depending on which IP got pinged, you could have problems.

chutz
  • 7,888
  • 1
  • 29
  • 59