[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

network subinterfaces script



Hello all.  I'm pretty new with Linux, but I absolutely love Debian.  I
work for a small ISP so we have lots of virtual hosts so naturally I
noticed debian was missing a slick packaged-up functionality for adding
network subinterfaces (aliases).  I wrote this little script to implement
such a slick interface.  It's just a little 5 minute script and I am by no
means the world's best sh programmer, so I don't know how useful it will
ultimately be to debian, but I thought I'd send it in and see if you'd like
to use it anyways. :)

Basically if this were inserted into the startup by default all the
administator would have to do would be to add a file /etc/X.aliases where X
is the name of an interface, and produce an appropriate kernel, and it
works.

here it is:

#! /bin/sh
# FILE /etc/init.d/netaliases

# list of interfaces on the system
INTERFACES="eth0 eth1 lo0 ppp0"
# flags to pass to ifconfig
FLAGS=""

count=1
echo -n "configuring network subinterfaces... "


for INTERFACE in ${INTERFACES}
do
	if [ -f /etc/${INTERFACE}.aliases ] ; then
		echo -n ${INTERFACE}
		for IPADDR in `cat /etc/${INTERFACE}.aliases | sed /^#/d`
		do
			ifconfig eth0:${count} ${IPADDR} ${FLAGS}
			count=$((${count}+1))
		done 
		echo -n ": $((${count}-1)) aliases "
	fi	
done
echo "."

--=-=-=-=-=-=-=-=-=
Barry J. Bocaner
<barry@gslink.com>
-=-=-=-=-=-=-=-=-=-


Reply to: