2002-07-18 05:00:17 +00:00
|
|
|
#!/bin/sh
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2000 The KAME Project
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
# SUCH DAMAGE.
|
|
|
|
#
|
2000-02-23 18:05:58 +00:00
|
|
|
# $FreeBSD$
|
2002-07-18 05:00:17 +00:00
|
|
|
# From: src/etc/rc.network6,v 1.29 2002/04/06 15:15:43
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
2000-02-23 18:05:58 +00:00
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
# PROVIDE: network_ipv6
|
2009-06-01 05:35:03 +00:00
|
|
|
# REQUIRE: routing ip6fw
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2000-02-23 18:05:58 +00:00
|
|
|
|
2003-04-29 12:08:43 +00:00
|
|
|
. /etc/rc.subr
|
2003-05-12 11:36:50 +00:00
|
|
|
. /etc/network.subr
|
2003-04-29 12:08:43 +00:00
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
name="network_ipv6"
|
|
|
|
rcvar=`set_rcvar ipv6`
|
|
|
|
start_cmd="network_ipv6_start"
|
|
|
|
|
|
|
|
network_ipv6_start()
|
|
|
|
{
|
|
|
|
# disallow "internal" addresses to appear on the wire
|
|
|
|
route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
|
|
|
|
route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
|
|
|
|
|
|
|
|
case ${ipv6_network_interfaces} in
|
|
|
|
[Aa][Uu][Tt][Oo])
|
|
|
|
# Get a list of network interfaces
|
|
|
|
ipv6_network_interfaces="`ifconfig -l`"
|
|
|
|
;;
|
|
|
|
[Nn][Oo][Nn][Ee])
|
|
|
|
ipv6_network_interfaces=''
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2002-10-12 10:31:31 +00:00
|
|
|
if checkyesno ipv6_gateway_enable; then
|
2002-07-18 05:00:17 +00:00
|
|
|
# act as a router
|
|
|
|
${SYSCTL_W} net.inet6.ip6.forwarding=1
|
|
|
|
${SYSCTL_W} net.inet6.ip6.accept_rtadv=0
|
|
|
|
|
|
|
|
# wait for DAD
|
|
|
|
for i in $ipv6_network_interfaces; do
|
|
|
|
ifconfig $i up
|
|
|
|
done
|
|
|
|
sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
|
|
|
|
sleep 1
|
|
|
|
else
|
|
|
|
# act as endhost - start with manual configuration
|
|
|
|
# Setup of net.inet6.ip6.accept_rtadv is done later by
|
|
|
|
# network6_interface_setup.
|
|
|
|
${SYSCTL_W} net.inet6.ip6.forwarding=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${ipv6_network_interfaces}" ]; then
|
|
|
|
# Setup the interfaces
|
|
|
|
network6_interface_setup $ipv6_network_interfaces
|
|
|
|
|
|
|
|
# wait for DAD's completion (for global addrs)
|
|
|
|
sleep `${SYSCTL_N} net.inet6.ip6.dad_count`
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Filter out interfaces on which IPv6 initialization failed.
|
2002-10-12 10:31:31 +00:00
|
|
|
if checkyesno ipv6_gateway_enable; then
|
2002-07-18 05:00:17 +00:00
|
|
|
ipv6_working_interfaces=""
|
|
|
|
for i in ${ipv6_network_interfaces}; do
|
|
|
|
laddr=`network6_getladdr $i exclude_tentative`
|
|
|
|
case ${laddr} in
|
|
|
|
'')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ipv6_working_interfaces="$i \
|
|
|
|
${ipv6_working_interfaces}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
ipv6_network_interfaces=${ipv6_working_interfaces}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup IPv6 to IPv4 mapping
|
|
|
|
network6_stf_setup
|
|
|
|
|
|
|
|
# Install the "default interface" to kernel, which will be used
|
|
|
|
# as the default route when there's no router.
|
|
|
|
network6_default_interface_setup
|
|
|
|
|
|
|
|
# Setup static routes
|
|
|
|
network6_static_routes_setup
|
|
|
|
|
|
|
|
# Setup faith
|
|
|
|
network6_faith_setup
|
|
|
|
|
|
|
|
# Support for IPv4 address tacked onto an IPv6 address
|
2002-10-12 10:31:31 +00:00
|
|
|
if checkyesno ipv6_ipv4mapping; then
|
2002-07-18 05:00:17 +00:00
|
|
|
echo 'IPv4 mapped IPv6 address support=YES'
|
|
|
|
${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null
|
|
|
|
else
|
|
|
|
echo 'IPv4 mapped IPv6 address support=NO'
|
|
|
|
${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|