1 #!/bin/sh 2 # 3 # $FreeBSD: head/etc/rc.d/ip6addrctl 270836 2014-08-30 07:08:10Z hrs $ 4 # 5 6 # PROVIDE: ip6addrctl 7 # REQUIRE: root bootconf mountcritlocal tty 8 9 . /etc/rc.subr 10 11 name="ip6addrctl" 12 rcvar="ip6addrctl_enable" 13 start_cmd="ip6addrctl_start" 14 stop_cmd="ip6addrctl_stop" 15 extra_commands="status prefer_ipv6 prefer_ipv4" 16 status_cmd="ip6addrctl" 17 prefer_ipv6_cmd="ip6addrctl_prefer_ipv6" 18 prefer_ipv4_cmd="ip6addrctl_prefer_ipv4" 19 config_file="/etc/ip6addrctl.conf" 20 21 IP6ADDRCTL_CMD="/usr/sbin/ip6addrctl" 22 23 ip6addrctl_prefer_ipv6() 24 { 25 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1 26 cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin 27 ::1/128 50 0 28 ::/0 40 1 29 ::ffff:0:0/96 35 4 30 2002::/16 30 2 31 2001::/32 5 5 32 fc00::/7 3 13 33 ::/96 1 3 34 fec0::/10 1 11 35 3ffe::/16 1 12 36 EOT 37 } 38 39 ip6addrctl_prefer_ipv4() 40 { 41 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1 42 cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin 43 ::1/128 50 0 44 ::/0 40 1 45 ::ffff:0:0/96 100 4 46 2002::/16 30 2 47 2001::/32 5 5 48 fc00::/7 3 13 49 ::/96 1 3 50 fec0::/10 1 11 51 3ffe::/16 1 12 52 EOT 53 } 54 55 ip6addrctl_start() 56 { 57 # install the policy of the address selection algorithm. 58 case "${ip6addrctl_policy}" in 59 [Aa][Uu][Tt][Oo]) 60 if [ -r "${config_file}" -a -s "${config_file}" ]; then 61 ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1 62 ${IP6ADDRCTL_CMD} install "${config_file}" 63 else 64 if checkyesno ipv6_activate_all_interfaces; then 65 ip6addrctl_prefer_ipv6 66 elif [ -n "$(list_vars ifconfig_\*_ipv6)" ]; then 67 ip6addrctl_prefer_ipv6 68 else 69 ip6addrctl_prefer_ipv4 70 fi 71 fi 72 ;; 73 ipv4_prefer) 74 ip6addrctl_prefer_ipv4 75 ;; 76 ipv6_prefer) 77 ip6addrctl_prefer_ipv6 78 ;; 79 *) 80 warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \ 81 " \"ipv4_prefer\" is used instead." 82 ip6addrctl_prefer_ipv4 83 ;; 84 esac 85 86 if checkyesno ip6addrctl_verbose; then 87 echo 'Address selection policy table for IPv4 and IPv6:' 88 ${IP6ADDRCTL_CMD} 89 fi 90 } 91 92 ip6addrctl_stop() 93 { 94 ip6addrctl flush >/dev/null 2>&1 95 } 96 97 load_rc_config $name 98 run_rc_command "$1" 99