Monday, January 30, 2012

Multiple IPs on a single LAN card

Configuring your LAN card to run multiple IPs in Slackware® Linux is as same as assigning address to different network interfaces. Just modify your /etc/rc.d/rc.inet1.conf file and restart the networking services and you are done.

All you have to do is to create different virtual interfaces and assign the IP. Virtual interfaces are created as eth0:1 (here, eth0 is the network interface and 1 is the virtual interface, for which we will configure additional IP on eth0 port).

For this, IFNAME[] is used. On my Slackware 13 machine running kernel 2.6.27, I modified my rc.inet1.conf file and included the following lines to configure one more IP on my eth0 interface:

IFNAME[2]="eth0:1"
IPADDR[2]="192.168.0.16"
NETMASK[2]="255.255.255.0"
USE_DHCP[2]=""
DHCP_HOSTNAME[2]=""

After modification, my rc.inet1.conf file looks like:

. . .
# Config information for eth0:
IPADDR[0]="192.168.1.16"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""

# Config information for eth1:
IPADDR[1]="xxx.xxx.xxx.xxx"
NETMASK[1]="255.255.255.224"
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""

# Config information for eth0:1:
IFNAME[2]="eth0:1"
IPADDR[2]="192.168.0.16"
NETMASK[2]="255.255.255.0"
USE_DHCP[2]=""
DHCP_HOSTNAME[2]=""
. . .

included just eth interfaces configuration portion(excluding gateway).
Here, on second network card(eth1) I’ve configured a different IP and two IPs(192.168.1.16 & 192.168.0.16) on my first LAN card(interface eth0).

You can do in same way. Just edit your rc.inet1.conf file by issuing following command:
vi /etc/rc.d/rc.inet1.conf make required changes(just like I did) and restart the services by issuing following command:
/etc/rc.d/rc.inet1 restartand you are done.

1 comment: