#!/bin/sh # # vlan configure the various vlan devices # chkconfig: - 11 89 # description: configure the various vlanxxxx devices for userfirewall # probe: true . /etc/rc.d/init.d/functions if [ ! -f /etc/userfirewall/vlan.conf ] ; then echo No /etc/userfirewall/vlan.conf, ending >&2 exit 0 fi if [ ! -x /sbin/vconfig ] ; then echo vlan utility /sbin/vconfig is not installed, ending >&2 exit 0 fi cd / case $1 in start) if [ ! -d /proc/net/vlan ] ; then echo Load vlan module 8021q /sbin/modprobe 8021q fi # vlan.n files contains # VLAN=n # DEVICE= # IPADDR= # NETMASK= for file in `ls /etc/userfirewall/vlan.[0-9]* | grep -v \~` do #echo file=$file unset ROUTE . $file VLAN0000=`printf "%04d" $VLAN` VLANDEV=vlan$VLAN0000 # Unconfigure the vlan, in case its was already configured /sbin/ifconfig $VLANDEV down 2>/dev/null /sbin/vconfig rem $VLANDEV 2>/dev/null /sbin/vconfig add $DEVICE $VLAN /sbin/ifconfig $VLANDEV $IPADDR broadcast $BCAST netmask $NETMASK if [ "$HOSTS" != "" ] ; then for h in $HOSTS do /sbin/route add -host $h dev $VLANDEV # Setup proxy arp # /sbin/arp -i $DEVICE -Ds $h $DEVICE pub # Proxy arp is now fully handled by genproxyarp done # Remove unneeded route eval `/usr/lib/linuxconf/lib/ifinfo $VLANDEV` /sbin/route del -net $IFINFONET netmask $NETMASK dev $VLANDEV fi # Setup other routes nr=0 while [ "${ROUTE[$nr]}" != "" ] do echo ${ROUTE[$nr]} | \ ( read net mask gtw && route add -net $net netmask $mask gw $gtw ) nr=`expr $nr + 1` done done /usr/lib/linuxconf/lib/genproxyarp --setup ;; restart) $0 stop $0 start ;; stop) for dev in `/usr/lib/linuxconf/lib/ifinfo --list` do case $dev in vlan*) /sbin/vconfig rem $dev ;; esac done ;; probe) ;; esac