ifconfig and virtual devices

Bobby Hitt (bobhitt@crosslink.net)
Fri, 12 Jun 1998 10:57:14 -0400


Hello all:

I've been using 2.0.33 ever since it's release with no problems. I seldom
even have to look at it, so the keyboard is covered with dust (Thanks
Linus!). The machine runs Apache 1.2.6, with 8 virtual servers mapped to the
same IP addess on the NIC as eth0:0 thru eth0:7. I have DNS records with all
enries as CNAMES to www.russianstory.com, whose IP address is
207.199.130.139. To set this up I use:

#!/bin/bash

# list of machine names to act as

names="www.ribcast.com \
www.isquare.com \
www.hillwoodinc.com \
www.fgwashingtonltd.com \
www.selfemployedwoman.com \
www.aluminumcase.com \
www.rackcases.com \
www.bscnet.com"

count=0

if [ "$1" = "stop" ]; then
for addr in $names
do
/sbin/route del $addr
/sbin/ifconfig eth0:$count- $addr
let count=$count+1
done

elif [ "$1" = "start" -o "$1" = "" ]; then
for addr in $names
do
/sbin/ifconfig eth0:$count $addr
/sbin/route add -host $addr dev eth0:$count
let count=$count+1
done
else
echo 'Usage: '$0' [start|stop]'
fi

Ifconfig produces this output:

lo Link encap:Local Loopback
inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0
UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1
RX packets:2556001 errors:0 dropped:0 overruns:0
TX packets:2556001 errors:0 dropped:0 overruns:0

eth0 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.191
Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12998891 errors:0 dropped:0 overruns:0
TX packets:13680652 errors:0 dropped:0 overruns:0
Interrupt:10 Base address:0x300

eth0:0 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:1 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:2 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:3 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:4 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:5 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:6 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

eth0:7 Link encap:10Mbps Ethernet HWaddr 00:C0:DF:45:C8:75
inet addr:207.199.130.139 Bcast:207.199.130.255
Mask:255.255.255.0
UP RUNNING MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0

Everything is peachy. Apache is happy, no problem accessing the virtuals.
I've been following the development of the 2.1.x kernels, and wanted to see
how it worked. I installed the 2.1.105 kernel, with "network aliasing" and
"IP: Aliasing support" checked. When I rebooted and ran the script listed
above, I got errors about "DEVICE EXISTS". What I found was that if I used
different IP addresses, it worked fine. Apache was fine, the virtuals were
accessible. All the documentation about IP aliasing referred to different IP
addresses. Since none of these virtuals need anything IP specific such as
virtual FTP, what do I need to do to have ifconfig add devices to the eth0
device with the same IP?

Any help is appreciated!

Bobby Hitt (bobhitt@bscnet.com)
Business Solutions, Consulting and Networking
(703) 754-8772

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu