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 set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces
26 set_rcvar_obsolete ipv6_prefer ip6addrctl_policy
28 IP6ADDRCTL_CMD="/usr/sbin/ip6addrctl"
30 ip6addrctl_prefer_ipv6()
32 afexists inet6 || return 0
34 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
35 cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
48 ip6addrctl_prefer_ipv4()
50 afexists inet6 || return 0
52 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
53 cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
68 afexists inet6 || return 0
70 # install the policy of the address selection algorithm.
71 case "${ip6addrctl_policy}" in
73 if [ -r "${config_file}" -a -s "${config_file}" ]; then
74 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
75 ${IP6ADDRCTL_CMD} install "${config_file}"
77 if checkyesno ipv6_activate_all_interfaces; then
78 ip6addrctl_prefer_ipv6
79 elif [ -n "$(list_vars ifconfig_\*_ipv6)" ]; then
80 ip6addrctl_prefer_ipv6
82 ip6addrctl_prefer_ipv4
87 ip6addrctl_prefer_ipv4
90 ip6addrctl_prefer_ipv6
92 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
93 # Backward compatibility when ipv6_prefer=YES
94 ip6addrctl_prefer_ipv6
96 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
97 # Backward compatibility when ipv6_prefer=NO
98 ip6addrctl_prefer_ipv4
101 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
104 warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
105 " \"ipv4_prefer\" is used instead."
106 ip6addrctl_prefer_ipv4
110 if checkyesno ip6addrctl_verbose; then
111 echo 'Address selection policy table for IPv4 and IPv6:'
118 afexists inet6 || return 0
120 ip6addrctl flush >/dev/null 2>&1