Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

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