IP Alias Configuration: The New Way
Copyright (C) 2002 by Steve Litt,
All rights reserved. Material provided as-is, use at your own risk.
IntroductionImagine my surprise when, after switching to Mandrake
9.0, I could no longer implement IP aliases. IP aliases are IP addresses,
in the same subnet as your ethernet card, which are aliases for the network
card's IP address. So if you ping an alias address you'll get a response
from your network card.
IP aliases probably have lots of uses, but I use them primarily for Apache
virtual hosts, resolving various domains to various IP aliases. That probably
is no longer necessary, but if for any reason you need IP aliases and the
old way of configuring them no longer works, use the new way.
The Old Way
In the old days, to enable a range of IP aliases from 192.168.100.100 through 192.168.100.110, you'd create the following /etc/sysconfig/network-scripts/ifcfg-eth0:0:
Alternatively, you'd identify the IP alias range with the linuxconf program that shipped with Linux, and that program would write your range to /etc/sysconfig/network-scripts/ifcfg-eth0:0:.
Unfortunately, on at least one distribution, Mandrake 9.0, not only does creating the /etc/sysconfig/network-scripts/ifcfg-eth0:0: not work, but its very existence prevents the new, correct method from working. What makes it really confusing is that the linuxconf program that ships with Mandrake 9.0 writes /etc/sysconfig/network-scripts/ifcfg-eth0:0:, so using it to modify an existing IP alias range will break existing IP alias ranges.
So if the old way works for you, fine. If not, try the new way. Read on...
The New Way
This is the way to enable IP alias ranges in Mandrake 9.0, and it probably
won't be the only distro implementing this method. Basically, IP alias ranges
are now kept in /etc/sysconfig/network-scripts/ifcfg-eth0-range0 instead of the old /etc/sysconfig/network-scripts/ifcfg-eth0:0:. Furthermore, the very existence of any file matching ifcfg-eth0:* prevents IP aliasing even with the correct method. So here's how you implement IP alias ranges the new way:
A few details. Obviously, if you're aliasing eth1, that fact would be reflected
in the filename in step 2. Likewise, if you have multiple ranges, you'd have
multiple files ifcfg-eth0-range0, ifcfg-eth0-range1, etc. Multiple ranges are a definite possiblity, because according to the comments in /etc/sysconfig/network-scripts/ifup-aliases, a range can be only a single class C, and must be in the same class C as the network card.
- Back up, then delete all files matching /etc/sysconfig/network-scripts/ifcfg-eth?:*
- Create the following /etc/sysconfig/network-scripts/ifcfg-eth0-range0:
- /etc/rc.d/init.d/network restart