From: <abe...@us...> - 2012-04-11 00:09:29
|
Revision: 5510 http://astlinux.svn.sourceforge.net/astlinux/?rev=5510&view=rev Author: abelbeck Date: 2012-04-11 00:09:23 +0000 (Wed, 11 Apr 2012) Log Message: ----------- network, add rc.conf variables EXTIP_ALIAS and EXT2IP_ALIAS, when defined with a 'static' EXTIP (or EXT2IP), alias interfaces for the IPv4 addresses in the variable are created. Modified Paths: -------------- branches/1.0/project/astlinux/target_skeleton/etc/init.d/functions branches/1.0/project/astlinux/target_skeleton/etc/init.d/network branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf Modified: branches/1.0/project/astlinux/target_skeleton/etc/init.d/functions =================================================================== --- branches/1.0/project/astlinux/target_skeleton/etc/init.d/functions 2012-04-10 17:47:56 UTC (rev 5509) +++ branches/1.0/project/astlinux/target_skeleton/etc/init.d/functions 2012-04-11 00:09:23 UTC (rev 5510) @@ -265,7 +265,7 @@ find_ip_from_if() { ip -o addr show dev "$1" \ - | awk '$3 == "inet" { split($4, field, "/"); print field[1]; }' + | awk '$3 == "inet" { split($4, field, "/"); print field[1]; nextfile; }' } nthfield() Modified: branches/1.0/project/astlinux/target_skeleton/etc/init.d/network =================================================================== --- branches/1.0/project/astlinux/target_skeleton/etc/init.d/network 2012-04-10 17:47:56 UTC (rev 5509) +++ branches/1.0/project/astlinux/target_skeleton/etc/init.d/network 2012-04-11 00:09:23 UTC (rev 5510) @@ -102,6 +102,31 @@ esac } +alias_interface() +{ + local action="$1" interface="$2" alias_list="$3" cnt alias IFS + + case $action in + + add) + cnt=1 + unset IFS + for alias in $alias_list; do + ip addr add $alias/32 dev $interface label ${interface}:${cnt} + cnt=$((cnt+1)) + done + ;; + + delete) + unset IFS + for alias in $alias_list; do + ip addr delete $alias/32 dev $interface + done + ;; + + esac +} + init () { if [ -n "$IFRENAME" ]; then @@ -405,6 +430,9 @@ ;; *) ifconfig $EXTIF $EXTIP netmask $EXTNM + if [ -n "$EXTIP_ALIAS" ]; then + alias_interface add $EXTIF "$EXTIP_ALIAS" + fi if [ "$IPV6" = "yes" -a -n "$EXTIPV6" ]; then ip -6 addr add $EXTIPV6 dev $EXTIF fi @@ -431,6 +459,9 @@ ;; *) ifconfig $EXT2IF $EXT2IP netmask $EXT2NM + if [ -n "$EXT2IP_ALIAS" ]; then + alias_interface add $EXT2IF "$EXT2IP_ALIAS" + fi if [ "$IPV6" = "yes" -a -n "$EXT2IPV6" ]; then ip -6 addr add $EXT2IPV6 dev $EXT2IF fi @@ -497,11 +528,17 @@ if [ -n "$EXTIF" -a "$EXTIF" != "none" ]; then echo "Bringing down $EXTIF..." + if [ -n "$EXTIP_ALIAS" ]; then + alias_interface delete $EXTIF "$EXTIP_ALIAS" + fi ifconfig $EXTIF down fi if [ -n "$EXT2IF" -a "$EXT2IF" != "none" ]; then echo "Bringing down $EXT2IF..." + if [ -n "$EXT2IP_ALIAS" ]; then + alias_interface delete $EXT2IF "$EXT2IP_ALIAS" + fi ifconfig $EXT2IF down fi Modified: branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf =================================================================== --- branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf 2012-04-10 17:47:56 UTC (rev 5509) +++ branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf 2012-04-11 00:09:23 UTC (rev 5510) @@ -703,6 +703,13 @@ ## If you are using PPPoE don't worry. We automatically handle those MTU issues #IFMTU="eth2.41:1496 eth0:1492" +## External Interface Alias (Virtual) IPv4 Addresses +## If EXTIP (or EXT2IP) is set, using a 'static' configuration, alias interfaces +## on EXTIF (or EXT2IF) may be defined creating $EXTIF:1, $EXTIF:2, etc. . +## Multiple IPv4 addresses are space separated. +#EXTIP_ALIAS="192.168.25.3 192.168.25.4" +#EXT2IP_ALIAS="192.168.25.3 192.168.25.4" + ## IFRENAME Support ## If for some reason you need to move your interfaces around before ## they are configured, you can do that here if you built your system This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |