[TriLUG] Multiple IP address per interface?

Benjamin Reed ranger at befunk.com
Sat Apr 6 20:34:36 EST 2002


Phillip Rhodes [mindcrime at cpphacker.co.uk] wrote:
> Question for all you Linux networking gurus.... can I have a particular
> interface (eth0 for example) assigned more than 1 IP address somehow?  If
> so, how would I go about doing so?
> 
> (note: if you're wondering why I need this, it's because I want to set up an
> additional Apache virtual host on this machine, and can't use named based
> virtual hosting because of SSL )

Yup... if you have a fairly modern distribution, you should just be able to
create an interface (eth0), and then you can configure any number of indexes
off of that interface (eth0:0, eth0:1, etc.).  So you can do something like:

ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0 up
...
ifconfig eth0:10 192.168.11.1 netmask 255.255.255.0 up

In redhat (and probably others), you can make a file called
"/etc/sysconfig/network-scripts/ifcfg-eth0:0" or similar and put whatever
configuration you want in it.

-- 
Benjamin Reed a.k.a. Ranger Rick (ranger at befunk.com) http://ranger.befunk.com/
Only Alex Chiu has the solution to a unified world, unless you can think of
a better one. -- Alex Chiu, Immortality Inventor



More information about the TriLUG mailing list