]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - etc/rc.d/network_ipv6
Add static routes to ::ffff:0.0.0.0/96 and ::0.0.0.0/96 unconditionally when
[FreeBSD/stable/8.git] / etc / rc.d / network_ipv6
1 #!/bin/sh
2 #
3 # Copyright (c) 2000  The KAME Project
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # $FreeBSD$
28 #       From: src/etc/rc.network6,v 1.29 2002/04/06 15:15:43
29 #
30
31 # PROVIDE: network_ipv6
32 # REQUIRE: routing
33 # KEYWORD: nojail
34
35 . /etc/rc.subr
36 . /etc/network.subr
37
38 name="network_ipv6"
39 rcvar="ipv6_enable"
40 start_cmd="network_ipv6_start"
41
42 network_ipv6_start()
43 {
44         case ${ipv6_network_interfaces} in
45         [Aa][Uu][Tt][Oo])
46                 # Get a list of network interfaces
47                 ipv6_network_interfaces="`ifconfig -l`"
48                 ;;
49         [Nn][Oo][Nn][Ee])
50                 ipv6_network_interfaces=''
51                 ;;
52         esac
53
54         if checkyesno ipv6_gateway_enable; then
55                 # act as a router
56                 ${SYSCTL_W} net.inet6.ip6.forwarding=1
57                 ${SYSCTL_W} net.inet6.ip6.accept_rtadv=0
58
59                 # wait for DAD
60                 for i in $ipv6_network_interfaces; do
61                         ifconfig $i up
62                 done
63                 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
64                 sleep 1
65         else
66                 # act as endhost - start with manual configuration
67                 # Setup of net.inet6.ip6.accept_rtadv is done later by
68                 # network6_interface_setup.
69                 ${SYSCTL_W} net.inet6.ip6.forwarding=0
70         fi
71
72         if [ -n "${ipv6_network_interfaces}" ]; then
73                 # Setup the interfaces
74                 network6_interface_setup $ipv6_network_interfaces
75
76                 # wait for DAD's completion (for global addrs)
77                 sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
78                 sleep 1
79         fi
80
81         # Filter out interfaces on which IPv6 initialization failed.
82         if checkyesno ipv6_gateway_enable; then
83                 ipv6_working_interfaces=""
84                 for i in ${ipv6_network_interfaces}; do
85                         laddr=`network6_getladdr $i exclude_tentative`
86                         case ${laddr} in
87                         '')
88                                 ;;
89                         *)
90                                 ipv6_working_interfaces="$i \
91                                     ${ipv6_working_interfaces}"
92                                 ;;
93                         esac
94                 done
95                 ipv6_network_interfaces=${ipv6_working_interfaces}
96         fi
97
98         # Setup IPv6 to IPv4 mapping
99         network6_stf_setup
100
101         # Install the "default interface" to kernel, which will be used
102         # as the default route when there's no router.
103         network6_default_interface_setup
104
105         # Setup static routes
106         network6_static_routes_setup
107
108         # Setup faith
109         network6_faith_setup
110
111         # Support for IPv4 address tacked onto an IPv6 address
112         if checkyesno ipv6_ipv4mapping; then
113                 echo 'IPv4 mapped IPv6 address support=YES'
114                 ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null
115         else
116                 echo 'IPv4 mapped IPv6 address support=NO'
117                 ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null
118         fi
119 }
120
121 load_rc_config $name
122 run_rc_command "$1"