Troubleshooters.Com and T.C Linux Library Present

IP Alias Configuration: The New Way

Copyright (C) 2002 by Steve Litt, All rights reserved. Material provided as-is, use at your own risk.


Steve Litt is the author of Troubleshooting Techniques of the Successful TechnologistRapid Learning: Secret Weapon of the Successful Technologist, and Samba Unleashed.

Introduction

Imagine 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:

IPADDR=192.168.100.100-110

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:

  1. Back up, then delete all files matching /etc/sysconfig/network-scripts/ifcfg-eth?:*
  2. Create the following /etc/sysconfig/network-scripts/ifcfg-eth0-range0:
    IPADDR_START=192.168.100.200
    IPADDR_END=192.168.100.219
    CLONENUM_START=0
  3. /etc/rc.d/init.d/network restart
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 to Troubleshooters.Com * Back to Linux Library