- Andrew Alston
- Tuesday, October 17th, 2006 at 10:49:03am UTC
- Some ip aliasing / vlan stuff
- Script for starting/stopping vlan interfaces:
- root@solaris /etc/rc3.d # more S19interface-vlan
- #!/sbin/sh
- #
- # Copyright 2006 Andrew Alston / TENET All rights reserved.
- #
- [ ! -d /usr/bin ] && exit
- # Start/stop processes required for starting and stopping vlans
- case "$1" in
- 'start')
- # If /etc/interface-vlan exists, use it to add virtual interfaces [this is syntax specific]
- if [ -f /etc/interface-vlan ]; then
- for i in `/usr/bin/cat /etc/interface-vlan |/usr/bin/grep -v '^#'`; do
- VLAN_INT=`/usr/bin/echo $i |awk -F: '{print $1SUM(($3*1000)+$2)}'`
- ADDRESS=`/usr/bin/echo $i |awk -F: '{print $4}'`;
- /sbin/ifconfig $VLAN_INT plumb $ADDRESS;
- done
- fi
- ;;
- 'stop')
- if [ -f /etc/interface-vlan ]; then
- for i in `/usr/bin/cat /etc/interface-vlan |/usr/bin/grep -v '^#'`; do
- VLAN_INT=`/usr/bin/echo $i |awk -F: '{print $1SUM(($3*1000)+$2)}'`
- /sbin/ifconfig $VLAN_INT unplumb;
- done
- fi
- ;;
- *)
- echo "Usage: $0 { start | stop }"
- exit 1
- ;;
- esac
- exit 0
- Example config file for vlans:
- root@solaris /etc/rc3.d # more ../interface-vlan
- # Syntax of this file is interface:instance:vlan-id
- e1000g:0:10:10.200.10.1/24
- e1000g:0:20:10.200.20.1/24
- e1000g:0:30:10.200.30.1/24
- e1000g:0:40:10.200.40.1/24
- Script for starting/stopping ip aliasing
- root@solaris /etc/rc3.d # more S20ip-alias
- #!/sbin/sh
- #
- # Copyright 2006 Andrew Alston / TENET All rights reserved.
- #
- [ ! -d /usr/bin ] && exit
- # Start/stop processes required for ip aliasing
- case "$1" in
- 'start')
- # If /etc/ip-aliases exists, use it to add virtual interfaces [this is syntax specific]
- if [ -f /etc/ip-aliases ]; then
- for i in `/usr/bin/cat /etc/ip-aliases |/usr/bin/grep -v '^#'`; do
- VLANID=`/usr/bin/echo $i |awk -F: '{print $1}'`;
- if [ $VLANID != 0 ]; then
- INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3SUM(($1*1000)+$2)}'`
- else
- INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3$2}'`;
- fi
- ADDRESS=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $4}'`;
- /sbin/ifconfig $INTERFACE addif $ADDRESS;
- done
- fi
- ;;
- 'stop')
- if [ -f /etc/ip-aliases ]; then
- for i in `/usr/bin/cat /etc/ip-aliases |/usr/bin/grep -v '^#'`; do
- VLANID=`/usr/bin/echo $i |awk -F: '{print $1}'`;
- if [ $VLANID != 0 ]; then
- INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3SUM(($1*1000)+$2)}'`
- else
- INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3$2}'`;
- fi
- ADDRESS=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $4}' |sed 's/\/.*//g'`;
- /sbin/ifconfig $INTERFACE removeif $ADDRESS;
- done
- fi
- ;;
- *)
- echo "Usage: $0 { start | stop }"
- exit 1
- ;;
- esac
- exit 0
- Example Configuration:
- root@solaris /etc/rc3.d # more /etc/ip-aliases
- # Format of this file is vlan:interface-instance:interface:address
- # vlan setting of 0 denotes no vlan config for that entry
- 0:0:e1000g:10.200.0.7/32
- 0:0:e1000g:10.200.0.75/32
- 0:0:e1000g:10.200.0.76/32
- 0:0:e1000g:10.200.0.77/32
- 0:0:e1000g:10.200.0.78
- 0:0:e1000g:10.200.0.79
- 0:0:e1000g:10.200.0.80
- 10:0:e1000g:10.200.10.81
- 20:0:e1000g:10.200.20.82
- 30:0:e1000g:10.200.30.83
- 40:0:e1000g:10.200.40.84
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.