[1108] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
| 3 | # ifdown-ipv6 |
---|
| 4 | # |
---|
| 5 | # |
---|
| 6 | # Taken from: |
---|
| 7 | # (P) & (C) 2000-2004 by Peter Bieringer <pb@bieringer.de> |
---|
| 8 | # |
---|
| 9 | # You will find more information on the initscripts-ipv6 homepage at |
---|
| 10 | # http://www.deepspace6.net/projects/initscripts-ipv6.html |
---|
| 11 | # |
---|
| 12 | # RHL integration assistance by Pekka Savola <pekkas@netcore.fi> |
---|
| 13 | # |
---|
| 14 | # Version 2005-09-22 |
---|
| 15 | # |
---|
| 16 | # Note: if called as (like normally) by /etc/sysconfig/network-scripts/ifdown |
---|
| 17 | # exit codes aren't handled by "ifdown" |
---|
| 18 | # |
---|
| 19 | # Uses following information from /etc/sysconfig/network-scripts/ifcfg-$1: |
---|
| 20 | # DEVICE=<device> |
---|
| 21 | # IPV6INIT=yes|no: controls IPv6 configuration for this interface |
---|
| 22 | # |
---|
| 23 | # Optional for 6to4 tunneling: |
---|
| 24 | # IPV6TO4_RELAY=<IPv4 address>: IPv4 address of the remote 6to4 relay [default: 192.88.99.1] |
---|
| 25 | # IPV6TO4_ROUTING="<device>-<suffix>/<prefix length> ...": information to setup internal interfaces |
---|
| 26 | # |
---|
| 27 | # Optional for 6to4 tunneling links to trigger radvd: |
---|
| 28 | # IPV6_CONTROL_RADVD=yes|no: controls radvd triggering [optional] |
---|
| 29 | # IPV6_RADVD_PIDFILE=<file>: PID file of radvd for sending signals, default is "/var/run/radvd/radvd.pid" [optional] |
---|
| 30 | # IPV6_RADVD_TRIGGER_ACTION=startstop|reload|restart|SIGHUP: how to trigger radvd [optional, default is SIGHUP] |
---|
| 31 | # |
---|
| 32 | # Required version of radvd to use 6to4 prefix recalculation |
---|
| 33 | # 0.6.2p3 or newer supporting option "Base6to4Interface" |
---|
| 34 | # Required version of radvd to use dynamic ppp links |
---|
| 35 | # 0.7.0 + fixes or newer |
---|
| 36 | # |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | . /etc/sysconfig/network |
---|
| 40 | |
---|
| 41 | cd /etc/sysconfig/network-scripts |
---|
[2573] | 42 | . /etc/sysconfig/network-scripts/network-functions |
---|
[1108] | 43 | |
---|
| 44 | CONFIG=$1 |
---|
| 45 | [ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG |
---|
| 46 | source_config |
---|
| 47 | |
---|
| 48 | # IPv6 don't need aliases anymore, config is skipped |
---|
| 49 | REALDEVICE=`echo ${DEVICE} | sed 's/:.*//g'` |
---|
| 50 | [ "$DEVICE" != "$REALDEVICE" ] && exit 0 |
---|
| 51 | |
---|
| 52 | [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 |
---|
| 53 | . /etc/sysconfig/network-scripts/network-functions-ipv6 |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | # IPv6 test, no module loaded, exit if system is not IPv6-ready |
---|
| 57 | ipv6_test testonly || exit 0 |
---|
| 58 | |
---|
| 59 | # Test device status |
---|
| 60 | ipv6_test_device_status $DEVICE |
---|
| 61 | if [ $? != 0 -a $? != 11 ]; then |
---|
| 62 | # device doesn't exist or other problem occurs |
---|
| 63 | exit 1 |
---|
| 64 | fi |
---|
| 65 | |
---|
| 66 | # Switch some sysctls to secure mode |
---|
| 67 | ipv6_exec_sysctl -w net.ipv6.conf.$DEVICE.forwarding=0 >/dev/null 2>&1 |
---|
| 68 | ipv6_exec_sysctl -w net.ipv6.conf.$DEVICE.accept_ra=0 >/dev/null 2>&1 |
---|
| 69 | ipv6_exec_sysctl -w net.ipv6.conf.$DEVICE.accept_redirects=0 >/dev/null 2>&1 |
---|
| 70 | |
---|
| 71 | # Test status of tun6to4 device |
---|
| 72 | ipv6_test_device_status tun6to4 |
---|
| 73 | if [ $? = 0 -o $? = 11 ]; then |
---|
| 74 | # Device exists |
---|
| 75 | valid6to4config="yes" |
---|
| 76 | |
---|
| 77 | if [ -z "$IPV6TO4_RELAY" ]; then |
---|
| 78 | IPV6TO4_RELAY="192.88.99.1" |
---|
| 79 | fi |
---|
| 80 | |
---|
| 81 | # Get IPv4 address from interface |
---|
| 82 | if [ -n "$IPV6TO4_IPV4ADDR" ]; then |
---|
| 83 | # Take special configured from config file (precedence 1) |
---|
| 84 | ipv4addr="$IPV6TO4_IPV4ADDR" |
---|
| 85 | |
---|
| 86 | # Get IPv4 address from interface first |
---|
| 87 | ipv4addrlocal="`ipv6_get_ipv4addr_of_device $DEVICE`" |
---|
| 88 | if [ -z "$ipv4addrlocal" ]; then |
---|
| 89 | # Take configured from config file |
---|
| 90 | ipv4addrlocal="$IPADDR" |
---|
| 91 | fi |
---|
| 92 | else |
---|
| 93 | # Get IPv4 address from interface first (has precedence 2) |
---|
| 94 | ipv4addr="`ipv6_get_ipv4addr_of_device $DEVICE`" |
---|
| 95 | if [ -z "$ipv4addr" ]; then |
---|
| 96 | # Take configured from config file (precedence 3) |
---|
| 97 | ipv4addr="$IPADDR" |
---|
| 98 | fi |
---|
| 99 | ipv4addrlocal="$ipv4addr" |
---|
| 100 | fi |
---|
| 101 | |
---|
| 102 | # Get local IPv4 address of dedicated tunnel |
---|
| 103 | ipv4addr6to4local="`ipv6_get_ipv4addr_of_tunnel tun6to4 local`" |
---|
| 104 | |
---|
| 105 | if [ -z "$ipv4addrlocal" -o -z "$ipv4addr6to4local" ]; then |
---|
| 106 | # no IPv4 addresses given, 6to4 sure not configured |
---|
| 107 | valid6to4config="no" |
---|
| 108 | else |
---|
| 109 | # Check against configured 6to4 tunnel to see if this interface was used before |
---|
| 110 | if [ "$ipv4addrlocal" != "$ipv4addr6to4local" ]; then |
---|
| 111 | # IPv4 address of interface does't match local tunnel address, interface was not used for current 6to4 setup |
---|
| 112 | valid6to4config="no" |
---|
| 113 | fi |
---|
| 114 | fi |
---|
| 115 | |
---|
| 116 | fi |
---|
| 117 | |
---|
| 118 | # Shutdown of 6to4, if configured |
---|
| 119 | if [ "$valid6to4config" = "yes" ]; then |
---|
| 120 | if [ -n "$IPV6TO4_ROUTING" ]; then |
---|
| 121 | # Delete routes to local networks |
---|
| 122 | for devsuf in $IPV6TO4_ROUTING; do |
---|
| 123 | dev="`echo $devsuf | awk -F- '{ print $1 }'`" |
---|
| 124 | ipv6_cleanup_6to4_device $dev |
---|
| 125 | done |
---|
| 126 | fi |
---|
| 127 | |
---|
| 128 | # Delete all configured 6to4 address |
---|
| 129 | ipv6_cleanup_6to4_tunnels tun6to4 |
---|
| 130 | |
---|
| 131 | # Control running radvd |
---|
| 132 | ipv6_trigger_radvd down "$IPV6_RADVD_TRIGGER_ACTION" $IPV6_RADVD_PIDFILE |
---|
| 133 | fi |
---|
| 134 | |
---|
| 135 | # Delete all current configured IPv6 addresses on this interface |
---|
| 136 | ipv6_cleanup_device $DEVICE |
---|