freebsd-dev/etc/rc.d/network_ipv6
Mike Makonnen 337338ee00 Remove the requirement for the FreeBSD keyword as it no longer
makes any sense.

Discussed with: dougb, brooks
MFC after: 3 days
2004-10-07 13:55:26 +00:00

127 lines
3.6 KiB
Bash

#!/bin/sh
#
# 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.
#
# $FreeBSD$
# From: src/etc/rc.network6,v 1.29 2002/04/06 15:15:43
#
# PROVIDE: network_ipv6
# REQUIRE: routing
# KEYWORD: nojail
. /etc/rc.subr
. /etc/network.subr
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
if checkyesno ipv6_gateway_enable; then
# 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.
if checkyesno ipv6_gateway_enable; then
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
if checkyesno ipv6_ipv4mapping; then
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"