3 # $FreeBSD: head/libexec/rc/rc.d/ip6addrctl 320802 2017-07-08 09:28:31Z kp $
7 # REQUIRE: root mountcritlocal
15 desc
="configure address selection policy for IPv6 and IPv4"
16 rcvar
="ip6addrctl_enable"
17 start_cmd
="ip6addrctl_start"
18 stop_cmd
="ip6addrctl_stop"
19 extra_commands
="status prefer_ipv6 prefer_ipv4"
20 status_cmd
="ip6addrctl"
21 prefer_ipv6_cmd
="ip6addrctl_prefer_ipv6"
22 prefer_ipv4_cmd
="ip6addrctl_prefer_ipv4"
23 config_file
="/etc/ip6addrctl.conf"
25 IP6ADDRCTL_CMD
="/usr/sbin/ip6addrctl"
28 ${SYSCTL} -q net.inet6
>/dev
/null ||
{
29 warn
"kernel does not support INET6"
34 ip6addrctl_prefer_ipv6
()
38 ${IP6ADDRCTL_CMD} flush
>/dev
/null
2>&1
39 cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
52 ip6addrctl_prefer_ipv4
()
56 ${IP6ADDRCTL_CMD} flush
>/dev
/null
2>&1
57 cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
74 # Install the policy of the address selection algorithm.
75 case "${ip6addrctl_policy}" in
77 if [ -r "${config_file}" -a -s "${config_file}" ]; then
78 ${IP6ADDRCTL_CMD} flush
>/dev
/null
2>&1
79 ${IP6ADDRCTL_CMD} install "${config_file}"
81 if checkyesno ipv6_enable
; then
82 ip6addrctl_prefer_ipv6
84 ip6addrctl_prefer_ipv4
89 ip6addrctl_prefer_ipv4
92 ip6addrctl_prefer_ipv6
95 ${IP6ADDRCTL_CMD} flush
>/dev
/null
2>&1
98 warn
"\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
99 " \"ipv4_prefer\" is used instead."
100 ip6addrctl_prefer_ipv4
104 if checkyesno ip6addrctl_verbose
; then
105 echo 'Address selection policy table for IPv4 and IPv6:'
112 has_inet6 ||
return 0
114 ip6addrctl flush
>/dev
/null
2>&1