proper ip address aliasing

Ken Scott kens at geodax.com
Thu Feb 3 13:46:44 UTC 2005


On Wed, 2005-02-02 at 19:20, Rick Stevens wrote:
> Ken Scott wrote:
> > On Wed, 2005-02-02 at 12:59, Rick Stevens wrote:
> > 
> >>jdyke wrote:
> >>
> >>>I need to add a group of virutal ips to a single interface on FC3. I've 
> >>>used
> >>>`ip addr add 192.168.2.XX dev eth0` to add the ips which worked fine, 
> >>>but what is the best/proper way to add them at boot up.  I'd assume i 
> >>>could add them in rc.local which should work?  but is that right?
> >>
> >>The proper way is to create additional scripts in the
> >>"/etc/sysconfig/network-scripts" directory.  They should be named
> >>"ifcfg-eth0:x", with "x" being the alias number.  If you're adding 3
> >>aliases to eth0, for example, the files would be:
> >>
> >>	ifcfg-eth0	(primary, leave it alone)
> >>	ifcfg-eth0:1	(first alias)
> >>	ifcfg-eth0:2	(second alias)
> >>	ifcfg-eth0:3	(third alias)
> >>
> >>Inside those "ifcfg-eth0:x" scripts, you only need four lines:
> >>
> >>	DEVICE=eth0:x		(replace "x" with the alias number)
> >>	IPADDR=xxx.xxx.xxx.xxx
> >>	NETMASK=xxx.xxx.xxx.xxx
> >>	ONBOOT=yes
> >>
> >>The first one, "ifcfg-eth0" should be left alone, as it sets up the
> >>base device.
> >>
> >>That's the "official" way to do it and the way "system-config-network"
> >>or "Fedora Icon->System Settings->Network" do it, which would allow you
> >>to manage them via the GUI system.
> > 
> > 
> > I have not had occasion to use this "virtual IP" technique but I
> > appreciate the procedure.
> 
> Technically it's called "IP aliasing".
> 
> >                            Does this mean that I can take my development
> > box (192.168.0.100) and assign it a virtual IP on a different subnet
> > (say 192.168.2.100)  so that it could talk to a another box I  have on
> > the local network temporarily (which I am working on for someone else)? 
> > My machine only has a single network card in it.
> 
> Yes you can, but you have to be careful as your switch/router may not
> allow you to cross subnet boundries.  For most people it'll work fine.
> 
> > That would be great if true, I could leave both my machine's IP alone
> > and the other device's IP as well and simply change the virtual IP so
> > that they could talk.
> 
> We do it a lot, but again, watch your routers and switches.  Also
> remember that your _default_ route will remain the same.  It will add
> another _network_ route, but not a default one.
> 
> > Seems so elegant that it probably does work that way (since it is after
> > all Linux)!
> 
> Simple is elegant.  That's Unix/Linux in a nutshell.
> 
> > I know that I can change my internal IP to match the target machine but
> > that solution doesn't allow concurrent web access.
> 
> This is the cheap solution.
> 
> Historical note:  Before hostheaders were invented in HTTP 1.1, this is
> how you got a web server to handle multiple websites.  Each site got an
> individual IP address and you aliased the NIC card out the wazoo.

Thanks a lot.  That is very helpful and informative.  One last perhaps
slightly off-forum question, is the configuration procedure above
specific to Red Hat/Fedora or does it apply more generally to other
Linux distributions (specifically Debian)?
Ken  




More information about the Redhat-install-list mailing list