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"
22 ROUTE_CMD="/sbin/route"
32 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy]) _if="" ;;
37 if afexists $_af; then
38 setroutes $_cmd $_af $_if
40 err 1 "Unsupported address family: $_af."
43 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
44 for _a in inet inet6 ipx atm; do
45 afexists $_a && setroutes $_cmd $_a $_if
49 err 1 "Unsupported address family: $_af."
61 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy]) _if="" ;;
66 if afexists $_af; then
67 eval static_${_af} delete $_if
68 # When $_if is specified, do not flush routes.
69 if ! [ -n "$_if" ]; then
70 eval routing_stop_${_af}
73 err 1 "Unsupported address family: $_af."
76 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
77 for _a in inet inet6 ipx atm; do
78 afexists $_a || continue
79 eval static_${_a} delete $_if
80 # When $_if is specified, do not flush routes.
81 if ! [ -n "$_if" ]; then
82 eval routing_stop_${_a}
87 err 1 "Unsupported address family: $_af."
110 ${ROUTE_CMD} -n flush -inet
117 ${ROUTE_CMD} -n flush -inet6
118 for i in `list_net_interfaces`; do
120 ifconfig $i inet6 -defaultif
137 local _action _if _skip
142 case ${defaultrouter} in
146 static_routes="${static_routes} _default"
147 route__default="default ${defaultrouter}"
151 # Install configured routes.
152 if [ -n "${static_routes}" ]; then
153 for i in ${static_routes}; do
155 if [ -n "$_if" ]; then
161 if [ $_skip = 0 ]; then
162 route_args=`get_if_var ${i%:*} route_IF`
163 if [ -n "$route_args" ]; then
164 ${ROUTE_CMD} ${_action} ${route_args}
166 warn "route_${i%:*} not found."
175 local _action _if _skip fibmod fibs
179 # get the number of FIBs supported.
180 fibs=$((`${SYSCTL_N} net.fibs` - 1))
181 if [ "$fibs" -gt 0 ]; then
182 fibmod="-fib 0-$fibs"
187 # Add pre-defined static routes first.
188 ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}"
189 ipv6_static_routes="_lla _llma ${ipv6_static_routes}"
191 # disallow "internal" addresses to appear on the wire
192 ipv6_route__v4mapped="::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
193 ipv6_route__v4compat="::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
195 # Disallow link-local unicast packets without outgoing scope
196 # identifiers. However, if you set "ipv6_default_interface",
197 # for the host case, you will allow to omit the identifiers.
198 # Under this configuration, the packets will go to the default
200 ipv6_route__lla="fe80:: -prefixlen 10 ::1 -reject ${fibmod}"
201 ipv6_route__llma="ff02:: -prefixlen 16 ::1 -reject ${fibmod}"
204 case ${ipv6_defaultrouter} in
208 ipv6_static_routes="${ipv6_static_routes} _default"
209 ipv6_route__default="default ${ipv6_defaultrouter}"
213 # Install configured routes.
214 if [ -n "${ipv6_static_routes}" ]; then
215 for i in ${ipv6_static_routes}; do
217 if [ -n "$_if" ]; then
223 if [ $_skip = 0 ]; then
224 ipv6_route_args=`get_if_var ${i%:*} ipv6_route_IF`
225 if [ -n "$ipv6_route_args" ]; then
226 ${ROUTE_CMD} ${_action} \
227 -inet6 ${ipv6_route_args}
229 warn "route_${i%:*} not found"
235 # Install the "default interface" to kernel, which will be used
236 # as the default route when there's no router.
238 # Disable installing the default interface when we act
239 # as router to avoid conflict between the default
240 # router list and the manual configured default route.
241 if checkyesno ipv6_gateway_enable; then
245 case "${ipv6_default_interface}" in
246 [Nn][Oo] | [Nn][Oo][Nn][Ee])
249 [Aa][Uu][Tt][Oo] | "")
250 for i in ${ipv6_network_interfaces}; do
259 laddr=`network6_getladdr $i exclude_tentative`
264 ipv6_default_interface=$i
272 ifconfig ${ipv6_default_interface} inet6 defaultif
273 sysctl net.inet6.ip6.use_defaultzone=1
278 local _action i route_args
281 if [ -n "${natm_static_routes}" ]; then
282 for i in ${natm_static_routes}; do
283 route_args=`get_if_var $i route_IF`
284 if [ -n "$route_args" ]; then
285 atmconfig natm ${_action} ${route_args}
287 warn "route_${i} not found."
300 if [ -z "${_ropts_initdone}" ]; then
301 echo -n "Additional $1 routing options:"
309 if checkyesno icmp_bmcastecho; then
311 echo -n ' broadcast ping responses=YES'
312 ${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null
314 ${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null
317 if checkyesno icmp_drop_redirect; then
319 echo -n ' ignore ICMP redirect=YES'
320 ${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null
322 ${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null
325 if checkyesno icmp_log_redirect; then
327 echo -n ' log ICMP redirect=YES'
328 ${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null
330 ${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null
333 if checkyesno gateway_enable; then
335 echo -n ' gateway=YES'
336 ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
338 ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
341 if checkyesno forward_sourceroute; then
343 echo -n ' do source routing=YES'
344 ${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
346 ${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null
349 if checkyesno accept_sourceroute; then
351 echo -n ' accept source routing=YES'
352 ${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
354 ${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null
357 if checkyesno arpproxy_all; then
359 echo -n ' ARP proxyall=YES'
360 ${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
362 ${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
365 [ -n "${_ropts_initdone}" ] && echo '.'
372 if checkyesno ipv6_gateway_enable; then
374 echo -n ' gateway=YES'
375 ${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
377 ${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
380 [ -n "${_ropts_initdone}" ] && echo '.'
387 [ -n "${_ropts_initdone}" ] && echo '.'
394 if checkyesno ipxgateway_enable; then
396 echo -n ' gateway=YES'
397 ${SYSCTL} net.ipx.ipx.ipxforwarding=1 > /dev/null
399 ${SYSCTL} net.ipx.ipx.ipxforwarding=0 > /dev/null
402 [ -n "${_ropts_initdone}" ] && echo '.'