source: projects/initscripts/tags/initscripts-8.91.0/sysconfig/network-scripts/init.ipv6-global @ 2576

Revision 2576, 5.0 KB checked in by daisuke, 13 years ago (diff)

tagging as initscripts-8.91.0

Line 
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
35cd /etc/sysconfig/network-scripts
36. /etc/sysconfig/network-scripts/network-functions
37
38# Get action and hook position
39ACTION="$1"
40POSITION="$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
46case $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                        # Host/Router behaviour for the interface
70                        ipv6_exec_sysctl -w net.ipv6.conf.$interface.forwarding=$ipv6_global_forwarding >/dev/null 2>&1
71
72                        # Autoconfiguration and redirect handling for Hosts
73                        ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_ra=$ipv6_global_auto >/dev/null 2>&1
74                        ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_redirects=$ipv6_global_auto >/dev/null 2>&1
75                done
76                ;;
77
78            post)
79                # IPv6 test, module loaded, exit if system is not IPv6-ready
80                ipv6_test || exit 1
81
82
83                if [ "$IPV6_AUTOTUNNEL" = "yes" ]; then
84                        ipv6_enable_autotunnel
85                        # autotunnel interface doesn't require a MTU setup
86                fi
87
88                ## Add some routes which should never appear on the wire
89                # Unreachable IPv4-only addresses, normally blocked by source address selection
90                ipv6_exec_ip route add unreach  ::ffff:0.0.0.0/96
91                # Unreachable IPv4-mapped addresses
92                ipv6_exec_ip route add unreach  ::0.0.0.0/96
93                # Unreachable 6to4: IPv4 multicast, reserved, limited broadcast
94                ipv6_exec_ip route add unreach  2002:e000::/19
95                # Unreachable 6to4: IPv4 loopback
96                ipv6_exec_ip route add unreach  2002:7f00::/24
97                # Unreachable 6to4: IPv4 private (RFC 1918)
98                ipv6_exec_ip route add unreach  2002:0a00::/24
99                ipv6_exec_ip route add unreach  2002:ac10::/28
100                ipv6_exec_ip route add unreach  2002:c0a8::/32
101                # Unreachable 6to4: IPv4 private (APIPA / DHCP link-local)
102                ipv6_exec_ip route add unreach  2002:a9fe::/32
103                # Unreachable IPv6: 6bone test addresses
104                ipv6_exec_ip route add unreach  3ffe:ffff::/32
105
106                # Set default route for autotunnel, if specified
107                if [ "$IPV6_DEFAULTDEV" = "sit0" -a "$IPV6_AUTOTUNNEL" = "yes" ]; then
108                        if [ -n "$IPV6_DEFAULTGW" ]; then
109                                ipv6_set_default_route $IPV6_DEFAULTGW $IPV6_DEFAULTDEV sit0
110                        elif [ -n "$IPV6_DEFAULTDEV" ]; then
111                                ipv6_set_default_route "" $IPV6_DEFAULTDEV sit0
112                        fi
113                fi
114                ;;
115
116            *)
117                echo "Usage: $0 $1 {pre|post}"
118                ;;
119
120        esac
121        ;;
122
123    stop)
124        case $POSITION in
125            pre)
126                # IPv6 test, no module loaded, exit if system is not IPv6-ready
127                ipv6_test testonly || exit 0
128
129
130                ;;
131
132            post)
133                # IPv6 test, no module loaded, exit if system is not IPv6-ready
134                ipv6_test testonly || exit 0
135
136
137                for i in /proc/sys/net/ipv6/conf/* ; do
138                        interface=${i##*/}
139                        # Assume Host behaviour
140                        ipv6_exec_sysctl -w net.ipv6.conf.$interface.forwarding=0 >/dev/null 2>&1
141
142                        # Disable autoconfiguration and redirects
143                        ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_ra=0 >/dev/null 2>&1
144                        ipv6_exec_sysctl -w net.ipv6.conf.$interface.accept_redirects=0 >/dev/null 2>&1
145                done
146
147                # Cleanup still existing tunnel devices
148                ipv6_cleanup_tunnel_devices
149
150                # Shut down generic tunnel interface now
151                ipv6_exec_ip link set sit0 down
152                ;;
153
154            *)
155                echo "Usage: $0 $1 {pre|post}"
156                ;;
157
158        esac
159        ;;
160
161    restart|reload)
162        # do nothing, will be handled by main script
163        ;;
164
165    showsysctl)
166        # Run only basic tests, no module is loaded, if not ok, skip IPv6 initialization
167        ipv6_test testonly || exit 0
168
169        # Show sysctl switches
170        sysctl net.ipv6.conf.default |awk -F '.' '{ print gensub(" =.*","","G",$5) }' | while read switch; do
171                for i in /proc/sys/net/ipv6/conf/* ; do
172                        interface=${i##*/}
173                        sysctl net.ipv6.conf.$interface.$switch
174                done
175                echo
176        done
177        ;;
178
179    *)
180        echo $"Usage: $0 {start|stop|reload|restart|showsysctl}"
181        exit 1
182        ;;
183esac
Note: See TracBrowser for help on using the repository browser.