Sunday, April 17, 2005

Linux Multiple IPs single computer

Setting Up Multiple IP Aliases In a Single File

This document will show you how to setup multiple IP aliases in a single file for use as a web server or simply a linux box that needs multiple IP's assigned to it.

1. cd /etc/sysconfig/network-scripts
2. pico ifcfg-eth0-range0
3. insert the following lines into the file

IPADDR_START=10.0.1.1
IPADDR_END=10.0.1.255
CLONENUM_START=0

the above lines will create 256 ipaddress you can use any combination of numbers as long as the numbers go from low to high.

You cannot repeat numbers for example if you created an ifcfg-eth0-range1 and tried to use
IPADDR_START=10.0.1.140 IPADDR_END=10.0.2.255 CLONENUM_START=0

THE FILE WOULD FAIL for several reasons

1. You cannot overlap ip addresses in this instance 140 had already been used.
2. The ip addresses must all be in the same class C (ie 192.168.2.0 - 192.168.2.255 192.168.99.0 - 192.168.99.255)
3. CLONENUM_START need to be sequencial since we used 256 clones in range0 we need CLONENUM_START=257 AND SO ON make sure there arent any backup coppies of the files in the /etc/sysconfig/network-scripts directory ir ~/etc/sysconfig/network-scripts or /etc/sysconfig/network-scripts~ as this will cause the startup to fail

To activate the ip aliases you need to type: > ifup ifcfg-eth0-range0 to verify that they are working type: >ping 10.0.1.111 or whatever ip address you have assigned ...

****personal note- don't just put this in ifcfg-eth0 - it will NOT work; also I've added ONBOOT=yes to the above


examples (first line of each block = filename):

ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=123.123.123.1

ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
ONBOOT=yes
IPADDR=123.123.123.2

ifcfg-eth0:2
DEVICE=eth0:2
BOOTPROTO=static
ONBOOT=yes
IPADDR=123.123.123.3

No comments: