4 # Note that almost all of the user-configurable behavior is no longer in
5 # this file, but rather in /etc/defaults/rc.conf. Please check that file
6 # first before contemplating any changes here. If you do need to change
7 # this file for some reason, we would like to know about it.
12 echo -n 'Doing IPv6 network setup:'
14 case ${ipv6_gateway_enable} in
17 # list of interfaces, and prefix for interfaces
19 case ${ipv6_network_interfaces} in
21 ipv6_network_interfaces="`ifconfig -l`"
27 # manual configurations - in case ip6_gateway_enable=NO
28 # you can configure only single interface,
29 # as specification assumes that
30 # autoconfigured host has single interface only.
32 case ${ipv6_network_interfaces} in
34 ipv6_network_interfaces="`ifconfig -l \
44 # disallow "internal" addresses to appear on the wire
45 route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
46 route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
48 case ${ipv6_gateway_enable} in
51 sysctl -w net.inet6.ip6.forwarding=1
52 sysctl -w net.inet6.ip6.accept_rtadv=0
55 for i in $ipv6_network_interfaces; do
58 sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'`
61 # setting up interfaces
62 for i in $ipv6_network_interfaces; do
63 eval prefix=\$ipv6_prefix_$i
69 for j in ${prefix}; do
70 case ${prefixcmd_enable} in
75 laddr=`ifconfig $i inet6 \
76 | grep 'inet6 fe80:' \
77 | head -1 | awk '{print $2}'`
78 hostid=`echo ${laddr} | sed \
79 -e 's/fe80:[0-9a-fA-F]+::/fe80::/' \
80 -e 's/fe80:://' -e 's/@.*//'`
83 eval hostid_$i=${hostid}
84 eval address_$i=${address}
86 ifconfig $i inet6 ${address} \
91 # subnet-router anycast address (rfc2373)
92 ifconfig $i inet6 $j:: prefixlen 64 \
99 # again, wait for DAD's completion (for global addrs)
100 sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'`
106 # install the "default interface" to kernel, which will be used
107 # as the default route when there's no router.
108 network6_default_interface_setup
111 case ${ipv6_router_enable} in
113 if [ -x ${ipv6_router} ]; then
114 echo -n " ${ipv6_router}"
115 ${ipv6_router} ${ipv6_router_flags}
121 # This should enabled with a great care.
122 # You may want to fine-tune /etc/rtadvd.conf.
124 # And if you wish your rtadvd to receive and process
125 # router renumbering messages, specify your Router Renumbering
126 # security policy by -P option.
128 # See `man 3 ipsec_set_policy` for IPsec policy specification
130 # (CAUTION: This enables your routers prefix renumbering
131 # from another machine, so if you enable this, do it with
134 case ${rtadvd_enable} in
137 rtadvd ${ipv6_network_interfaces}
139 # Enable Router Renumbering, unicast case
140 # (use correct src/dst addr)
141 # rtadvd -P "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" \
142 ${ipv6_network_interfaces}
143 # Enable Router Renumbering, multicast case
144 # (use correct src addr)
145 # rtadvd -P "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" \
146 ${ipv6_network_interfaces}
151 case ${mroute6d_enable} in
153 if [ -x ${mroute6d_program} ]; then
154 echo -n " ${mroute6d_program}"
155 ${mroute6d_program} ${mroute6d_flags}
161 # act as endhost - automatically configured
162 sysctl -w net.inet6.ip6.forwarding=0
163 sysctl -w net.inet6.ip6.accept_rtadv=1
165 ifconfig ${ipv6_network_interfaces} up
166 rtsol ${ipv6_network_interfaces}
170 # wait for DAD's completion (for global addrs)
171 sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'`
177 # install the "default interface" to kernel, which will be used
178 # as the default route when there's no router.
179 # ndp -I ${ipv6_default_interface}
180 network6_default_interface_setup
186 # Let future generations know we made it.
188 network6_pass1_done=YES
191 network6_gif_setup() {
192 case ${gif_interfaces} in
196 for i in ${gif_interfaces}; do
197 eval peers=\$gifconfig_$i
203 gifconfig $i ${peers}
211 network6_default_interface_setup() {
212 # Choose IPv6 default interface if it is not clearly specified.
213 case ${ipv6_default_interface} in
215 for i in ${ipv6_network_interfaces}; do
216 laddr=`ifconfig $i inet6 | grep 'inet6 fe80:' | \
217 head -1 | grep -v tentative`
222 ipv6_default_interface=$i
230 # Disallow unicast packets without outgoing scope identifiers,
231 # or route such packets to a "default" interface, if it is specified.
232 case ${ipv6_default_interface} in
234 route add -inet6 fe80:: -prefixlen 10 ::1 -reject
235 route add -inet6 ff02:: -prefixlen 16 ::1 -reject
238 laddr=`ifconfig ${ipv6_default_interface} inet6 \
239 | grep 'inet6 fe80:' | head -1 | awk '{print $2}'`
240 route add -inet6 fe80:: ${laddr} -prefixlen 10 -interface \
242 route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \