3 |
- |
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
|
|
|
42 |
. ./network-functions
|
|
|
43 |
|
|
|
44 |
CONFIG=$1
|
|
|
45 |
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
|
|
|
46 |
source_config
|
|
|
47 |
|
|
|
48 |
REALDEVICE=${DEVICE%%:*}
|
|
|
49 |
DEVICE=$REALDEVICE
|
|
|
50 |
|
|
|
51 |
[ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1
|
|
|
52 |
. /etc/sysconfig/network-scripts/network-functions-ipv6
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
# IPv6 test, no module loaded, exit if system is not IPv6-ready
|
|
|
56 |
ipv6_test testonly || exit 0
|
|
|
57 |
|
|
|
58 |
# Test device status
|
|
|
59 |
ipv6_test_device_status $DEVICE
|
|
|
60 |
if [ $? != 0 -a $? != 11 ]; then
|
|
|
61 |
# device doesn't exist or other problem occurs
|
|
|
62 |
exit 1
|
|
|
63 |
fi
|
|
|
64 |
|
|
|
65 |
# Switch some sysctls to secure mode
|
|
|
66 |
/sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.forwarding=0 >/dev/null 2>&1
|
|
|
67 |
/sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_ra=0 >/dev/null 2>&1
|
|
|
68 |
/sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_redirects=0 >/dev/null 2>&1
|
|
|
69 |
|
|
|
70 |
# Test status of tun6to4 device
|
|
|
71 |
ipv6_test_device_status tun6to4
|
|
|
72 |
if [ $? = 0 -o $? = 11 ]; then
|
|
|
73 |
# Device exists
|
|
|
74 |
valid6to4config="yes"
|
|
|
75 |
|
|
|
76 |
if [ -z "$IPV6TO4_RELAY" ]; then
|
|
|
77 |
IPV6TO4_RELAY="192.88.99.1"
|
|
|
78 |
fi
|
|
|
79 |
|
|
|
80 |
# Get IPv4 address from interface
|
|
|
81 |
if [ -n "$IPV6TO4_IPV4ADDR" ]; then
|
|
|
82 |
# Take special configured from config file (precedence 1)
|
|
|
83 |
ipv4addr="$IPV6TO4_IPV4ADDR"
|
|
|
84 |
|
|
|
85 |
# Get IPv4 address from interface first
|
|
|
86 |
ipv4addrlocal="$(ipv6_get_ipv4addr_of_device $DEVICE)"
|
|
|
87 |
if [ -z "$ipv4addrlocal" ]; then
|
|
|
88 |
# Take configured from config file
|
|
|
89 |
ipv4addrlocal="$IPADDR"
|
|
|
90 |
fi
|
|
|
91 |
else
|
|
|
92 |
# Get IPv4 address from interface first (has precedence 2)
|
|
|
93 |
ipv4addr="$(ipv6_get_ipv4addr_of_device $DEVICE)"
|
|
|
94 |
if [ -z "$ipv4addr" ]; then
|
|
|
95 |
# Take configured from config file (precedence 3)
|
|
|
96 |
ipv4addr="$IPADDR"
|
|
|
97 |
fi
|
|
|
98 |
ipv4addrlocal="$ipv4addr"
|
|
|
99 |
fi
|
|
|
100 |
|
|
|
101 |
# Get local IPv4 address of dedicated tunnel
|
|
|
102 |
ipv4addr6to4local="$(ipv6_get_ipv4addr_of_tunnel tun6to4 local)"
|
|
|
103 |
|
|
|
104 |
if [ -z "$ipv4addrlocal" -o -z "$ipv4addr6to4local" ]; then
|
|
|
105 |
# no IPv4 addresses given, 6to4 sure not configured
|
|
|
106 |
valid6to4config="no"
|
|
|
107 |
else
|
|
|
108 |
# Check against configured 6to4 tunnel to see if this interface was used before
|
|
|
109 |
if [ "$ipv4addrlocal" != "$ipv4addr6to4local" ]; then
|
|
|
110 |
# IPv4 address of interface does't match local tunnel address, interface was not used for current 6to4 setup
|
|
|
111 |
valid6to4config="no"
|
|
|
112 |
fi
|
|
|
113 |
fi
|
|
|
114 |
|
|
|
115 |
fi
|
|
|
116 |
|
|
|
117 |
# Shutdown of 6to4, if configured
|
|
|
118 |
if [ "$valid6to4config" = "yes" ]; then
|
|
|
119 |
if [ -n "$IPV6TO4_ROUTING" ]; then
|
|
|
120 |
# Delete routes to local networks
|
|
|
121 |
for devsuf in $IPV6TO4_ROUTING; do
|
|
|
122 |
dev="$(echo $devsuf | awk -F- '{ print $1 }')"
|
|
|
123 |
ipv6_cleanup_6to4_device $dev
|
|
|
124 |
done
|
|
|
125 |
fi
|
|
|
126 |
|
|
|
127 |
# Delete all configured 6to4 address
|
|
|
128 |
ipv6_cleanup_6to4_tunnels tun6to4
|
|
|
129 |
|
|
|
130 |
# Control running radvd
|
|
|
131 |
ipv6_trigger_radvd down "$IPV6_RADVD_TRIGGER_ACTION" $IPV6_RADVD_PIDFILE
|
|
|
132 |
fi
|
|
|
133 |
|
|
|
134 |
# Delete all current configured IPv6 addresses on this interface
|
|
|
135 |
ipv6_cleanup_device $DEVICE
|