blob: 88e1f990f0e262ac5e256b18a6cd6a8f2ebdedc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ip6addrctl
# REQUIRE: FILESYSTEMS netif
# BEFORE: network_ipv6
# KEYWORD: nojail
. /etc/rc.subr
name="ip6addrctl"
rcvar=`set_rcvar`
start_cmd="ip6addrctl_start"
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"
ip6addrctl_prefer_ipv6()
{
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()
{
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
}
ip6addrctl_start()
{
if ifconfig lo0 inet6 >/dev/null 2>&1; then
# We have IPv6 support in kernel.
# install the policy of the address selection algorithm.
if [ -f /etc/ip6addrctl.conf ]; then
ip6addrctl flush >/dev/null 2>&1
ip6addrctl install /etc/ip6addrctl.conf
checkyesno ip6addrctl_verbose && ip6addrctl
else
if checkyesno ipv6_enable; then
ip6addrctl_prefer_ipv6
else
ip6addrctl_prefer_ipv4
fi
fi
fi
}
ip6addrctl_stop()
{
if ifconfig lo0 inet6 >/dev/null 2>&1; then
# We have IPv6 support in kernel.
ip6addrctl flush >/dev/null 2>&1
fi
}
load_rc_config $name
run_rc_command "$1"
|