3 # Configure routing and miscellaneous network tunables
9 # REQUIRE: faith netif ppp stf
16 start_cmd="routing_start doall"
17 stop_cmd="routing_stop"
18 extra_commands="options static"
19 static_cmd="routing_start static"
20 options_cmd="routing_start options"
25 ""|inet|inet6|ipx|atm)
28 err 1 "Unsupported address family: $_af."
46 for _a in inet inet6 ipx atm; do
47 afexists $_a && setroutes $_cmd $_a
62 eval static_${_af} delete
63 eval routing_stop_${_af}
66 for _a in inet inet6 ipx atm; do
67 afexists $_a || continue
68 eval static_${_a} delete
69 eval routing_stop_${_a}
100 route -n flush -inet6
101 for i in `list_net_interfaces`; do
103 ifconfig $i inet6 -defaultif
123 case ${defaultrouter} in
127 static_routes="default ${static_routes}"
128 route_default="default ${defaultrouter}"
132 if [ -n "${static_routes}" ]; then
133 for i in ${static_routes}; do
134 route_args=`get_if_var $i route_IF`
135 route ${_action} ${route_args}
145 # get the number of FIBs supported.
146 fibs=`sysctl -n net.fibs`
149 # disallow "internal" addresses to appear on the wire
150 route ${_action} -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
151 route ${_action} -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
153 if test ${i} -lt ${fibs}; then
154 printf "Also installing reject routes for FIBs"
155 while test ${i} -lt ${fibs}; do
156 setfib -F ${i} route -q ${_action} \
157 -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
158 setfib -F ${i} route -q ${_action} \
159 -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
166 case ${ipv6_defaultrouter} in
170 ipv6_static_routes="default ${ipv6_static_routes}"
171 ipv6_route_default="default ${ipv6_defaultrouter}"
175 if [ -n "${ipv6_static_routes}" ]; then
176 for i in ${ipv6_static_routes}; do
177 ipv6_route_args=`get_if_var $i ipv6_route_IF`
178 route ${_action} -inet6 ${ipv6_route_args}
182 # Fixup $ipv6_network_interfaces
183 case ${ipv6_network_interfaces} in
185 ipv6_network_interfaces=''
189 if checkyesno ipv6_gateway_enable; then
190 for i in ${ipv6_network_interfaces}; do
192 laddr=`network6_getladdr $i exclude_tentative`
197 ipv6_working_interfaces="$i \
198 ${ipv6_working_interfaces}"
202 ipv6_network_interfaces=${ipv6_working_interfaces}
205 # Install the "default interface" to kernel, which will be used
206 # as the default route when there's no router.
207 case "${ipv6_default_interface}" in
208 [Nn][Oo] | [Nn][Oo][Nn][Ee])
209 ipv6_default_interface=""
211 [Aa][Uu][Tt][Oo] | "")
212 for i in ${ipv6_network_interfaces}; do
218 laddr=`network6_getladdr $i exclude_tentative`
223 ipv6_default_interface=$i
231 # Disallow link-local unicast packets without outgoing scope
232 # identifiers. However, if you set "ipv6_default_interface",
233 # for the host case, you will allow to omit the identifiers.
234 # Under this configuration, the packets will go to the default
236 route ${_action} -inet6 fe80:: -prefixlen 10 ::1 -reject
237 route ${_action} -inet6 ff02:: -prefixlen 16 ::1 -reject
239 if test ${i} -lt ${fibs}; then
240 printf "Also installing reject routes for FIBs"
241 while test ${i} -lt ${fibs}; do
242 setfib -F ${i} route -q ${_action} \
243 -inet6 fe80:: -prefixlen 10 ::1 -reject
244 setfib -F ${i} route -q ${_action} \
245 -inet6 ff02:: -prefixlen 16 ::1 -reject
252 case ${ipv6_default_interface} in
256 # Disable installing the default interface when we act
257 # as router to avoid conflict between the default
258 # router list and the manual configured default route.
259 if ! checkyesno ipv6_gateway_enable; then
260 ifconfig ${ipv6_default_interface} inet6 defaultif
261 sysctl net.inet6.ip6.use_defaultzone=1
269 local _action i route_args
272 if [ -n "${natm_static_routes}" ]; then
273 for i in ${natm_static_routes}; do
274 route_args=`get_if_var $i route_IF`
275 atmconfig natm ${_action} ${route_args}
287 if [ -z "${_ropts_initdone}" ]; then
288 echo -n "Additional $1 routing options:"
296 if checkyesno icmp_bmcastecho; then
298 echo -n ' broadcast ping responses=YES'
299 ${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null
301 ${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null
304 if checkyesno icmp_drop_redirect; then
306 echo -n ' ignore ICMP redirect=YES'
307 ${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null
309 ${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null
312 if checkyesno icmp_log_redirect; then
314 echo -n ' log ICMP redirect=YES'
315 ${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null
317 ${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null
320 if checkyesno gateway_enable; then
322 echo -n ' gateway=YES'
323 ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
325 ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
328 if checkyesno forward_sourceroute; then
330 echo -n ' do source routing=YES'
331 ${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
333 ${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null
336 if checkyesno accept_sourceroute; then
338 echo -n ' accept source routing=YES'
339 ${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
341 ${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null
344 if checkyesno arpproxy_all; then
346 echo -n ' ARP proxyall=YES'
347 ${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
349 ${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
352 [ -n "${_ropts_initdone}" ] && echo '.'
359 if checkyesno ipv6_gateway_enable; then
361 echo -n ' gateway=YES'
362 ${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
364 ${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
367 [ -n "${_ropts_initdone}" ] && echo '.'
374 [ -n "${_ropts_initdone}" ] && echo '.'
381 if checkyesno ipxgateway_enable; then
383 echo -n ' gateway=YES'
384 ${SYSCTL} net.ipx.ipx.ipxforwarding=1 > /dev/null
386 ${SYSCTL} net.ipx.ipx.ipxforwarding=0 > /dev/null
389 [ -n "${_ropts_initdone}" ] && echo '.'