3 # Configure routing and miscellaneous network tunables
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"
26 local _cmd _af _if _a _ret
33 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy]) _if="" ;;
37 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
38 for _a in inet inet6 atm; do
39 afexists $_a || continue
40 setroutes $_cmd $_a $_if || _ret=1
44 if afexists $_af; then
45 setroutes $_cmd $_af $_if || _ret=1
47 err 1 "Unsupported address family: $_af."
62 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy]) _if="" ;;
66 ""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
67 for _a in inet inet6 atm; do
68 afexists $_a || continue
69 eval static_${_a} delete $_if
70 # When $_if is specified, do not flush routes.
71 if ! [ -n "$_if" ]; then
72 eval routing_stop_${_a}
77 if afexists $_af; then
78 eval static_${_af} delete $_if
79 # When $_if is specified, do not flush routes.
80 if ! [ -n "$_if" ]; then
81 eval routing_stop_${_af}
84 err 1 "Unsupported address family: $_af."
108 ${ROUTE_CMD} -n flush -inet
115 ${ROUTE_CMD} -n flush -inet6
116 for i in `list_net_interfaces`; do
118 ifconfig $i inet6 -defaultif
130 local _action _if _skip
135 case ${defaultrouter} in
139 static_routes="${static_routes} _default"
140 route__default="default ${defaultrouter}"
144 # Install configured routes.
145 if [ -n "${static_routes}" ]; then
146 for i in ${static_routes}; do
148 if [ -n "$_if" ]; then
154 if [ $_skip = 0 ]; then
155 route_args=`get_if_var ${i%:*} route_IF`
156 if [ -n "$route_args" ]; then
157 ${ROUTE_CMD} ${_action} ${route_args}
159 warn "route_${i%:*} not found."
168 local _action _if _skip fibmod fibs
172 # get the number of FIBs supported.
173 fibs=$((`${SYSCTL_N} net.fibs` - 1))
174 if [ "$fibs" -gt 0 ]; then
175 fibmod="-fib 0-$fibs"
180 # Add pre-defined static routes first.
181 ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}"
182 ipv6_static_routes="_lla _llma ${ipv6_static_routes}"
184 # disallow "internal" addresses to appear on the wire
185 ipv6_route__v4mapped="::ffff:0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
186 ipv6_route__v4compat="::0.0.0.0 -prefixlen 96 ::1 -reject ${fibmod}"
188 # Disallow link-local unicast packets without outgoing scope
189 # identifiers. However, if you set "ipv6_default_interface",
190 # for the host case, you will allow to omit the identifiers.
191 # Under this configuration, the packets will go to the default
193 ipv6_route__lla="fe80:: -prefixlen 10 ::1 -reject ${fibmod}"
194 ipv6_route__llma="ff02:: -prefixlen 16 ::1 -reject ${fibmod}"
197 case ${ipv6_defaultrouter} in
201 ipv6_static_routes="${ipv6_static_routes} _default"
202 ipv6_route__default="default ${ipv6_defaultrouter}"
206 # Install configured routes.
207 if [ -n "${ipv6_static_routes}" ]; then
208 for i in ${ipv6_static_routes}; do
210 if [ -n "$_if" ]; then
216 if [ $_skip = 0 ]; then
217 ipv6_route_args=`get_if_var ${i%:*} ipv6_route_IF`
218 if [ -n "$ipv6_route_args" ]; then
219 ${ROUTE_CMD} ${_action} \
220 -inet6 ${ipv6_route_args}
222 warn "route_${i%:*} not found"
228 # Install the "default interface" to kernel, which will be used
229 # as the default route when there's no router.
231 # Disable installing the default interface when we act
232 # as router to avoid conflict between the default
233 # router list and the manual configured default route.
234 if checkyesno ipv6_gateway_enable; then
238 case "${ipv6_default_interface}" in
239 [Nn][Oo] | [Nn][Oo][Nn][Ee])
242 [Aa][Uu][Tt][Oo] | "")
243 for i in ${ipv6_network_interfaces}; do
252 laddr=`network6_getladdr $i exclude_tentative`
257 ipv6_default_interface=$i
265 ifconfig ${ipv6_default_interface} inet6 defaultif
266 sysctl net.inet6.ip6.use_defaultzone=1
271 local _action i route_args
274 if [ -n "${natm_static_routes}" ]; then
275 for i in ${natm_static_routes}; do
276 route_args=`get_if_var $i route_IF`
277 if [ -n "$route_args" ]; then
278 atmconfig natm ${_action} ${route_args}
280 warn "route_${i} not found."
288 if [ -z "${_ropts_initdone}" ]; then
289 echo -n "Additional $1 routing options:"
297 if checkyesno icmp_bmcastecho; then
299 echo -n ' broadcast ping responses=YES'
300 ${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null
302 ${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null
305 if checkyesno icmp_drop_redirect; then
307 echo -n ' ignore ICMP redirect=YES'
308 ${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null
310 ${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null
313 if checkyesno icmp_log_redirect; then
315 echo -n ' log ICMP redirect=YES'
316 ${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null
318 ${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null
321 if checkyesno gateway_enable; then
323 echo -n ' gateway=YES'
324 ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
326 ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
329 if checkyesno forward_sourceroute; then
331 echo -n ' do source routing=YES'
332 ${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
334 ${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null
337 if checkyesno accept_sourceroute; then
339 echo -n ' accept source routing=YES'
340 ${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
342 ${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null
345 if checkyesno arpproxy_all; then
347 echo -n ' ARP proxyall=YES'
348 ${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
350 ${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
353 [ -n "${_ropts_initdone}" ] && echo '.'
360 if checkyesno ipv6_gateway_enable; then
362 echo -n ' gateway=YES'
363 ${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
365 ${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
368 [ -n "${_ropts_initdone}" ] && echo '.'
375 [ -n "${_ropts_initdone}" ] && echo '.'