defaultroute revision 179079
1#!/bin/sh 2# 3# Configure routing and miscellaneous network tunables 4# 5# $FreeBSD: head/etc/rc.d/routing 179079 2008-05-18 02:57:54Z brooks $ 6# 7 8# PROVIDE: routing 9# REQUIRE: devd netif ppp 10# KEYWORD: nojail 11 12. /etc/rc.subr 13. /etc/network.subr 14 15name="routing" 16start_cmd="routing_start" 17stop_cmd="routing_stop" 18extra_commands="options static" 19static_cmd="static_start" 20options_cmd="options_start" 21 22routing_start() 23{ 24 static_start 25 options_start 26 27 # Return without waiting if we don't have dhcp interfaces. 28 # Once we can test that the link is actually up, we should 29 # remove this test and always wait. 30 dhcp_interfaces=`list_net_interfaces dhcp` 31 [ -z "`list_net_interfaces dhcp`" ] && return 32 33 # Wait for a default route 34 delay=${if_up_delay} 35 while [ ${delay} -gt 0 ]; do 36 defif=`get_default_if -inet` 37 if [ -n "${defif}" ]; then 38 if [ ${delay} -ne ${if_up_delay} ]; then 39 echo "($defif)" 40 fi 41 break 42 fi 43 if [ ${delay} -eq ${if_up_delay} ]; then 44 echo -n "Waiting ${delay}s for an interface to come up: " 45 else 46 echo -n . 47 fi 48 sleep 1 49 delay=`expr $delay - 1` 50 done 51} 52 53routing_stop() 54{ 55 route -n flush 56} 57 58static_start() 59{ 60 case ${defaultrouter} in 61 [Nn][Oo] | '') 62 ;; 63 *) 64 static_routes="default ${static_routes}" 65 route_default="default ${defaultrouter}" 66 ;; 67 esac 68 69 # Setup static routes. This should be done before router discovery. 70 # 71 if [ -n "${static_routes}" ]; then 72 for i in ${static_routes}; do 73 eval route_args=\$route_${i} 74 route add ${route_args} 75 done 76 fi 77 # Now ATM static routes 78 # 79 if [ -n "${natm_static_routes}" ]; then 80 for i in ${natm_static_routes}; do 81 eval route_args=\$route_${i} 82 atmconfig natm add ${route_args} 83 done 84 fi 85} 86 87options_start() 88{ 89 echo -n 'Additional routing options:' 90 case ${icmp_bmcastecho} in 91 [Yy][Ee][Ss]) 92 echo -n ' broadcast ping responses=YES' 93 sysctl net.inet.icmp.bmcastecho=1 >/dev/null 94 ;; 95 esac 96 97 case ${icmp_drop_redirect} in 98 [Yy][Ee][Ss]) 99 echo -n ' ignore ICMP redirect=YES' 100 sysctl net.inet.icmp.drop_redirect=1 >/dev/null 101 ;; 102 esac 103 104 case ${icmp_log_redirect} in 105 [Yy][Ee][Ss]) 106 echo -n ' log ICMP redirect=YES' 107 sysctl net.inet.icmp.log_redirect=1 >/dev/null 108 ;; 109 esac 110 111 case ${gateway_enable} in 112 [Yy][Ee][Ss]) 113 echo -n ' IP gateway=YES' 114 sysctl net.inet.ip.forwarding=1 >/dev/null 115 ;; 116 esac 117 118 case ${forward_sourceroute} in 119 [Yy][Ee][Ss]) 120 echo -n ' do source routing=YES' 121 sysctl net.inet.ip.sourceroute=1 >/dev/null 122 ;; 123 esac 124 125 case ${accept_sourceroute} in 126 [Yy][Ee][Ss]) 127 echo -n ' accept source routing=YES' 128 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null 129 ;; 130 esac 131 132 case ${ipxgateway_enable} in 133 [Yy][Ee][Ss]) 134 echo -n ' IPX gateway=YES' 135 sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null 136 ;; 137 esac 138 139 case ${arpproxy_all} in 140 [Yy][Ee][Ss]) 141 echo -n ' ARP proxyall=YES' 142 sysctl net.link.ether.inet.proxyall=1 >/dev/null 143 ;; 144 esac 145 146 echo '.' 147} 148 149load_rc_config $name 150run_rc_command "$1" 151