Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Andrew Alston
Tuesday, October 17th, 2006 at 10:49:03am UTC 

  1. Some ip aliasing / vlan stuff
  2.  
  3. Script for starting/stopping vlan interfaces:
  4.  
  5. root@solaris /etc/rc3.d # more S19interface-vlan
  6. #!/sbin/sh
  7. #
  8. # Copyright 2006 Andrew Alston / TENET  All rights reserved.
  9. #
  10.  
  11. [ ! -d /usr/bin ] && exit
  12.  
  13. # Start/stop processes required for  starting and stopping vlans
  14.  
  15. case "$1" in
  16. 'start')
  17.  
  18.         # If /etc/interface-vlan exists, use it to add virtual interfaces [this is syntax specific]
  19.  
  20.         if [ -f /etc/interface-vlan ]; then
  21.                 for i in `/usr/bin/cat /etc/interface-vlan |/usr/bin/grep -v '^#'`; do
  22.                      VLAN_INT=`/usr/bin/echo $i |awk -F: '{print $1SUM(($3*1000)+$2)}'`
  23.                      ADDRESS=`/usr/bin/echo $i |awk -F: '{print $4}'`;
  24.                      /sbin/ifconfig $VLAN_INT plumb $ADDRESS;
  25.                 done
  26.         fi
  27.         ;;
  28.  
  29. 'stop')
  30.         if [ -f /etc/interface-vlan ]; then
  31.                 for i in `/usr/bin/cat /etc/interface-vlan |/usr/bin/grep -v '^#'`; do
  32.                      VLAN_INT=`/usr/bin/echo $i |awk -F: '{print $1SUM(($3*1000)+$2)}'`
  33.                      /sbin/ifconfig $VLAN_INT unplumb;
  34.                 done
  35.         fi
  36.         ;;
  37. *)
  38.         echo "Usage: $0 { start | stop }"
  39.         exit 1
  40.         ;;
  41. esac
  42. exit 0
  43.  
  44. Example config file for vlans:
  45.  
  46. root@solaris /etc/rc3.d # more ../interface-vlan
  47. # Syntax of this file is interface:instance:vlan-id
  48. e1000g:0:10:10.200.10.1/24
  49. e1000g:0:20:10.200.20.1/24
  50. e1000g:0:30:10.200.30.1/24
  51. e1000g:0:40:10.200.40.1/24
  52.  
  53.  
  54. Script for starting/stopping ip aliasing
  55.  
  56. root@solaris /etc/rc3.d # more S20ip-alias
  57. #!/sbin/sh
  58. #
  59. # Copyright 2006 Andrew Alston / TENET  All rights reserved.
  60. #
  61.  
  62. [ ! -d /usr/bin ] && exit
  63.  
  64. # Start/stop processes required for ip aliasing
  65.  
  66. case "$1" in
  67. 'start')
  68.  
  69.         # If /etc/ip-aliases exists, use it to add virtual interfaces [this is syntax specific]
  70.  
  71.         if [ -f /etc/ip-aliases ]; then
  72.                 for i in `/usr/bin/cat /etc/ip-aliases |/usr/bin/grep -v '^#'`; do
  73.                    VLANID=`/usr/bin/echo $i |awk -F: '{print $1}'`;
  74.                    if [ $VLANID != 0 ]; then
  75.                        INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3SUM(($1*1000)+$2)}'`
  76.                    else
  77.                        INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3$2}'`;
  78.                    fi
  79.                    ADDRESS=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $4}'`;
  80.                    /sbin/ifconfig $INTERFACE addif $ADDRESS;
  81.                 done
  82.         fi
  83.         ;;
  84.  
  85. 'stop')
  86.         if [ -f /etc/ip-aliases ]; then
  87.                 for i in `/usr/bin/cat /etc/ip-aliases |/usr/bin/grep -v '^#'`; do
  88.                    VLANID=`/usr/bin/echo $i |awk -F: '{print $1}'`;
  89.                    if [ $VLANID != 0 ]; then
  90.                        INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3SUM(($1*1000)+$2)}'`
  91.                    else
  92.                        INTERFACE=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $3$2}'`;
  93.                    fi
  94.                    ADDRESS=`/usr/bin/echo $i |/usr/bin/awk -F: '{print $4}' |sed 's/\/.*//g'`;
  95.                    /sbin/ifconfig $INTERFACE removeif $ADDRESS;
  96.                 done
  97.         fi
  98.         ;;
  99. *)
  100.         echo "Usage: $0 { start | stop }"
  101.         exit 1
  102.         ;;
  103. esac
  104. exit 0
  105.  
  106. Example Configuration:
  107.  
  108. root@solaris /etc/rc3.d # more /etc/ip-aliases
  109. # Format of this file is vlan:interface-instance:interface:address
  110. # vlan setting of 0 denotes no vlan config for that entry
  111. 0:0:e1000g:10.200.0.7/32
  112. 0:0:e1000g:10.200.0.75/32
  113. 0:0:e1000g:10.200.0.76/32
  114. 0:0:e1000g:10.200.0.77/32
  115. 0:0:e1000g:10.200.0.78
  116. 0:0:e1000g:10.200.0.79
  117. 0:0:e1000g:10.200.0.80
  118. 10:0:e1000g:10.200.10.81
  119. 20:0:e1000g:10.200.20.82
  120. 30:0:e1000g:10.200.30.83
  121. 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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

comments powered by Disqus
worth-right
worth-right