1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
#!/bin/sh
#
# init.ipv6-global
#
#
# Taken from: init.ipv6-global
# (P) & (C) 2001-2005 by Peter Bieringer <pb@bieringer.de>
#
# You will find more information on the initscripts-ipv6 homepage at
# http://www.deepspace6.net/projects/initscripts-ipv6.html
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
# Version: 2005-01-04
#
# Calling parameters:
# $1: action (currently supported: start|stop|showsysctl)
# $2: position for start|stop (currently supported: pre|post)
#
# Called by hooks from /etc/[rc.d/]init.d/network
#
# Uses following information from /etc/sysconfig/network:
# IPV6FORWARDING=yes|no: controls global IPv6 forwarding (default: no)
# IPV6_AUTOCONF=yes|no: controls global automatic IPv6 configuration
# (default: yes if IPV6FORWARDING=no, no if IPV6FORWARDING=yes)
# IPV6_AUTOTUNNEL=yes|no: controls automatic IPv6 tunneling (default: no)
# IPV6_DEFAULTGW=<ipv6address[%interface]> [optional]
# IPV6_DEFAULTDEV=<interface> [optional]
#
. /etc/sysconfig/network
cd /etc/sysconfig/network-scripts
. ./network-functions
# Get action and hook position
ACTION="$1"
POSITION="$2"
[ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1
. /etc/sysconfig/network-scripts/network-functions-ipv6
# Initialize IPv6, depending on caller option
case $ACTION in
start)
case $POSITION in
pre)
# IPv6 test, module loaded, exit if system is not IPv6-ready
ipv6_test || exit 1
if [ "$IPV6FORWARDING" = "yes" ]; then
ipv6_global_forwarding=1
ipv6_global_auto=0
else
ipv6_global_forwarding=0
if [ "$IPV6_AUTOCONF" = "no" ]; then
ipv6_global_auto=0
else
ipv6_global_auto=1
fi
fi
# Reset IPv6 sysctl switches for "all", "default" and still existing devices
for i in /proc/sys/net/ipv6/conf/* ; do
interface=${i##*/}
# Host/Router behaviour for the interface
ipv6_exec_sysctl -w net.ipv6.conf.$interface.forwarding=$ipv6_global_forwarding >/dev/null 2>&1
# Autoconfiguration and redirect handling for Hosts
ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_ra=$ipv6_global_auto >/dev/null 2>&1
ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_redirects=$ipv6_global_auto >/dev/null 2>&1
done
;;
post)
# IPv6 test, module loaded, exit if system is not IPv6-ready
ipv6_test || exit 1
if [ "$IPV6_AUTOTUNNEL" = "yes" ]; then
ipv6_enable_autotunnel
# autotunnel interface doesn't require a MTU setup
fi
## Add some routes which should never appear on the wire
# Unreachable IPv4-only addresses, normally blocked by source address selection
ipv6_exec_ip route add unreach ::ffff:0.0.0.0/96
# Unreachable IPv4-mapped addresses
ipv6_exec_ip route add unreach ::0.0.0.0/96
# Unreachable 6to4: IPv4 multicast, reserved, limited broadcast
ipv6_exec_ip route add unreach 2002:e000::/19
# Unreachable 6to4: IPv4 loopback
ipv6_exec_ip route add unreach 2002:7f00::/24
# Unreachable 6to4: IPv4 private (RFC 1918)
ipv6_exec_ip route add unreach 2002:0a00::/24
ipv6_exec_ip route add unreach 2002:ac10::/28
ipv6_exec_ip route add unreach 2002:c0a8::/32
# Unreachable 6to4: IPv4 private (APIPA / DHCP link-local)
ipv6_exec_ip route add unreach 2002:a9fe::/32
# Unreachable IPv6: 6bone test addresses
ipv6_exec_ip route add unreach 3ffe:ffff::/32
# Set default route for autotunnel, if specified
if [ "$IPV6_DEFAULTDEV" = "sit0" -a "$IPV6_AUTOTUNNEL" = "yes" ]; then
if [ -n "$IPV6_DEFAULTGW" ]; then
ipv6_set_default_route $IPV6_DEFAULTGW $IPV6_DEFAULTDEV sit0
elif [ -n "$IPV6_DEFAULTDEV" ]; then
ipv6_set_default_route "" $IPV6_DEFAULTDEV sit0
fi
fi
;;
*)
echo "Usage: $0 $1 {pre|post}"
;;
esac
;;
stop)
case $POSITION in
pre)
# IPv6 test, no module loaded, exit if system is not IPv6-ready
ipv6_test testonly || exit 0
;;
post)
# IPv6 test, no module loaded, exit if system is not IPv6-ready
ipv6_test testonly || exit 0
for i in /proc/sys/net/ipv6/conf/* ; do
interface=${i##*/}
# Assume Host behaviour
ipv6_exec_sysctl -w net.ipv6.conf.$interface.forwarding=0 >/dev/null 2>&1
# Disable autoconfiguration and redirects
ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_ra=0 >/dev/null 2>&1
ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_redirects=0 >/dev/null 2>&1
done
# Cleanup still existing tunnel devices
ipv6_cleanup_tunnel_devices
# Shut down generic tunnel interface now
ipv6_exec_ip link set sit0 down
;;
*)
echo "Usage: $0 $1 {pre|post}"
;;
esac
;;
restart|reload)
# do nothing, will be handled by main script
;;
showsysctl)
# Run only basic tests, no module is loaded, if not ok, skip IPv6 initialization
ipv6_test testonly || exit 0
# Show sysctl switches
sysctl net.ipv6.conf.default |awk -F '.' '{ print gensub(" =.*","","G",$5) }' | while read switch; do
for i in /proc/sys/net/ipv6/conf/* ; do
interface=${i##*/}
sysctl net.ipv6.conf.$interface.$switch
done
echo
done
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|showsysctl}"
exit 1
;;
esac
|