2003-10-30 17:55:52 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ip6addrctl
|
2009-09-12 22:13:41 +00:00
|
|
|
# REQUIRE: FILESYSTEMS
|
|
|
|
# BEFORE: netif
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2003-10-30 17:55:52 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
2009-10-02 02:24:25 +00:00
|
|
|
. /etc/network.subr
|
2003-10-30 17:55:52 +00:00
|
|
|
|
|
|
|
name="ip6addrctl"
|
2004-06-02 09:39:49 +00:00
|
|
|
rcvar=`set_rcvar`
|
2003-10-30 17:55:52 +00:00
|
|
|
start_cmd="ip6addrctl_start"
|
2004-06-02 09:39:49 +00:00
|
|
|
stop_cmd="ip6addrctl_stop"
|
|
|
|
extra_commands="status prefer_ipv6 prefer_ipv4"
|
|
|
|
status_cmd="ip6addrctl"
|
|
|
|
prefer_ipv6_cmd="ip6addrctl_prefer_ipv6"
|
|
|
|
prefer_ipv4_cmd="ip6addrctl_prefer_ipv4"
|
2010-09-13 19:55:40 +00:00
|
|
|
config_file="/etc/ip6addrctl.conf"
|
2004-06-02 09:39:49 +00:00
|
|
|
|
2010-09-13 19:55:40 +00:00
|
|
|
set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces
|
|
|
|
set_rcvar_obsolete ipv6_prefer ip6addrctl_policy
|
2010-09-13 19:51:15 +00:00
|
|
|
|
2004-06-02 09:39:49 +00:00
|
|
|
ip6addrctl_prefer_ipv6()
|
|
|
|
{
|
2009-10-02 02:24:25 +00:00
|
|
|
afexists inet6 || return 0
|
|
|
|
|
2004-06-02 09:39:49 +00:00
|
|
|
ip6addrctl flush >/dev/null 2>&1
|
|
|
|
ip6addrctl add ::1/128 50 0
|
|
|
|
ip6addrctl add ::/0 40 1
|
|
|
|
ip6addrctl add 2002::/16 30 2
|
|
|
|
ip6addrctl add ::/96 20 3
|
|
|
|
ip6addrctl add ::ffff:0:0/96 10 4
|
|
|
|
checkyesno ip6addrctl_verbose && ip6addrctl
|
|
|
|
}
|
|
|
|
|
|
|
|
ip6addrctl_prefer_ipv4()
|
|
|
|
{
|
2009-10-02 02:24:25 +00:00
|
|
|
afexists inet6 || return 0
|
|
|
|
|
2004-06-02 09:39:49 +00:00
|
|
|
ip6addrctl flush >/dev/null 2>&1
|
|
|
|
ip6addrctl add ::ffff:0:0/96 50 0
|
|
|
|
ip6addrctl add ::1/128 40 1
|
|
|
|
ip6addrctl add ::/0 30 2
|
|
|
|
ip6addrctl add 2002::/16 20 3
|
|
|
|
ip6addrctl add ::/96 10 4
|
|
|
|
checkyesno ip6addrctl_verbose && ip6addrctl
|
|
|
|
}
|
2003-10-30 17:55:52 +00:00
|
|
|
|
|
|
|
ip6addrctl_start()
|
|
|
|
{
|
2009-10-02 02:24:25 +00:00
|
|
|
afexists inet6 || return 0
|
2003-10-30 17:55:52 +00:00
|
|
|
|
2009-10-02 02:24:25 +00:00
|
|
|
# install the policy of the address selection algorithm.
|
2010-09-13 19:55:40 +00:00
|
|
|
case "${ip6addrctl_policy}" in
|
|
|
|
[Aa][Uu][Tt][Oo])
|
|
|
|
if [ -r "${config_file}" -a -s "${config_file}" ]; then
|
|
|
|
ip6addrctl flush >/dev/null 2>&1
|
|
|
|
ip6addrctl install "${config_file}"
|
|
|
|
checkyesno ip6addrctl_verbose && ip6addrctl
|
2004-06-02 09:39:49 +00:00
|
|
|
else
|
2010-09-13 19:55:40 +00:00
|
|
|
if checkyesno ipv6_activate_all_interfaces; then
|
|
|
|
ip6addrctl_prefer_ipv6
|
|
|
|
else
|
|
|
|
ip6addrctl_prefer_ipv4
|
|
|
|
fi
|
2003-10-30 17:55:52 +00:00
|
|
|
fi
|
2010-09-13 19:55:40 +00:00
|
|
|
;;
|
|
|
|
ipv4_prefer)
|
|
|
|
ip6addrctl_prefer_ipv4
|
|
|
|
;;
|
|
|
|
ipv6_prefer)
|
|
|
|
ip6addrctl_prefer_ipv6
|
|
|
|
;;
|
|
|
|
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
|
|
|
|
# Backward compatibility when ipv6_prefer=YES
|
|
|
|
ip6addrctl_prefer_ipv6
|
|
|
|
;;
|
|
|
|
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
|
|
|
|
# Backward compatibility when ipv6_prefer=NO
|
|
|
|
ip6addrctl_prefer_ipv4
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
|
|
|
|
" \"ipv4_prefer\" is used instead."
|
|
|
|
ip6addrctl_prefer_ipv4
|
|
|
|
;;
|
|
|
|
esac
|
2003-10-30 17:55:52 +00:00
|
|
|
}
|
|
|
|
|
2004-06-02 09:39:49 +00:00
|
|
|
ip6addrctl_stop()
|
|
|
|
{
|
2009-10-02 02:24:25 +00:00
|
|
|
afexists inet6 || return 0
|
|
|
|
|
|
|
|
ip6addrctl flush >/dev/null 2>&1
|
2004-06-02 09:39:49 +00:00
|
|
|
}
|
|
|
|
|
2003-10-30 17:55:52 +00:00
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|