Operating System - Linux
1754954 Members
3327 Online
108827 Solutions
New Discussion юеВ

Create Virtual IP Address

 
SOLVED
Go to solution
Cliff Lim Kok Hwee
Regular Advisor

Create Virtual IP Address

Gd Day Forum,

Currently, I need to create a virtural ip address under the eth0 NIC.

Currently, under the following directory, /etc/sysconfig/network-scripts
-rw-r--r-- 1 root root 97 Sep 8 2004 ifcfg-eth0

How do I proceed to do it?

Thanks/cliff

9 REPLIES 9
Stuart Browne
Honored Contributor
Solution

Re: Create Virtual IP Address

create '/etc/sysconfig/network=scripts/ifcfg-eth0:0' with:

IPADDR=
DEVICE=eth0:0
ONBOOT=Yes
TYPE=Ethernet
BOOTPROTO=static
NETMASK=

then type 'ifup eth0:0' to put it in place.
One long-haired git at your service...
Muthukumar_5
Honored Contributor

Re: Create Virtual IP Address

Create as,

ifconfig eth0:0 netmask

For permanent effect, create a file as suggested by stuart.

hth.
Easy to suggest when don't know about the problem!
Cliff Lim Kok Hwee
Regular Advisor

Re: Create Virtual IP Address

Thanks to Stuart and Muthukumar,

It works :)

Created the ifcfg-eth0:0 file for permanent effect after a reboot.

But i started it as eth0:1 instead....rather then eth0:0. Any convention to follow instead?

Thanks/cliff
Stuart Browne
Honored Contributor

Re: Create Virtual IP Address

You should start at :0, as that's the first aliased interface.
One long-haired git at your service...
Cliff Lim Kok Hwee
Regular Advisor

Re: Create Virtual IP Address

Thanks Stuart :)
TheDude_1
New Member

Re: Create Virtual IP Address

are there any guidelines for the netmask associated with a virtual IP?

Should one make their default IP address something like 10.0.0.2 with a netmask of 255.0.0.0 and then add a virtual ip address of 10.0.0.200 with a netmask of 255.255.255.255 or should the netmask of the virtual ip also be 255.0.0.0?

If you do the later, is there any risk of packets being routed out the wrong ip (whether syn or ack?) If you do the former, is there a risk of creating a "local router" problem?

Do firewalls/routers mind sending traffic back out on to their local network where it received the data from?

I've done a few google searches on this but it seems like people who add the entire netmask on to their vip's are also doing fun things like manual load balancing through routing.

Are there any specific RFC's out there for this?
Stuart Browne
Honored Contributor

Re: Create Virtual IP Address

You treat a 'virtual ip' (it's called aliasing in Linux) as you would a normal interface IP.

You subnet it based on what traffic you want through that interface (whether it's virtual or physical).

That being said, I've never seen a situation in a business where an 8bit subnet mask is needed on a client or server (do you honestly have an office with over 16 million devices?), only on dedicated routers.
One long-haired git at your service...
TheDude_1
New Member

Re: Create Virtual IP Address

I used a class A address as an example. I certainly do not need that many. (It's actually a /22 in a different class)


>>You subnet it based on what traffic you want through that interface (whether it's virtual or physical).

What is the default action on linux's routing table for initiating connections bound for the same network that multiple aliases reside on.

For instance, you decide to build a tcp connection and send a packet to a separate host on your network. Which ip does the routing table decide to source the packet from when all aliases have the same netmask?

Is linux's default reaction always to use the first interface defined? Or does it use the physical interface over an alias?
Stuart Browne
Honored Contributor

Re: Create Virtual IP Address

It will usually use the IP of the interface (virtual or physical) the packet will traverse first.

Actually, lets clear this up a little bit. Since late 2.2.x series of kernels, there has been no 'physical interface ip address' and 'virtual' addresses. They are all 'virtual' addresses, which are bound to a 'physical' interface.

But anyway, Linux will take the ip from the interface it traverses, not the 'first' addressed attached to they physical interface, or the 'primary' address (which occurs in other Unicies i've used over the years).
One long-haired git at your service...