routing revision 179079
1100280Sgordon#!/bin/sh 225184Sjkh# 3100280Sgordon# Configure routing and miscellaneous network tunables 466830Sobrien# 550472Speter# $FreeBSD: head/etc/rc.d/routing 179079 2008-05-18 02:57:54Z brooks $ 666830Sobrien# 725184Sjkh 8117019Smtm# PROVIDE: routing 9179079Sbrooks# REQUIRE: devd netif ppp 10136224Smtm# KEYWORD: nojail 1125184Sjkh 12100280Sgordon. /etc/rc.subr 13179079Sbrooks. /etc/network.subr 1425184Sjkh 15117019Smtmname="routing" 16117019Smtmstart_cmd="routing_start" 17117019Smtmstop_cmd="routing_stop" 18117019Smtmextra_commands="options static" 19117019Smtmstatic_cmd="static_start" 20117019Smtmoptions_cmd="options_start" 2185831Sdes 22117019Smtmrouting_start() 23100280Sgordon{ 24117019Smtm static_start 25117019Smtm options_start 26179079Sbrooks 27179079Sbrooks # Return without waiting if we don't have dhcp interfaces. 28179079Sbrooks # Once we can test that the link is actually up, we should 29179079Sbrooks # remove this test and always wait. 30179079Sbrooks dhcp_interfaces=`list_net_interfaces dhcp` 31179079Sbrooks [ -z "`list_net_interfaces dhcp`" ] && return 32179079Sbrooks 33179079Sbrooks # Wait for a default route 34179079Sbrooks delay=${if_up_delay} 35179079Sbrooks while [ ${delay} -gt 0 ]; do 36179079Sbrooks defif=`get_default_if -inet` 37179079Sbrooks if [ -n "${defif}" ]; then 38179079Sbrooks if [ ${delay} -ne ${if_up_delay} ]; then 39179079Sbrooks echo "($defif)" 40179079Sbrooks fi 41179079Sbrooks break 42179079Sbrooks fi 43179079Sbrooks if [ ${delay} -eq ${if_up_delay} ]; then 44179079Sbrooks echo -n "Waiting ${delay}s for an interface to come up: " 45179079Sbrooks else 46179079Sbrooks echo -n . 47179079Sbrooks fi 48179079Sbrooks sleep 1 49179079Sbrooks delay=`expr $delay - 1` 50179079Sbrooks done 51117019Smtm} 52117019Smtm 53117019Smtmrouting_stop() 54117019Smtm{ 55117019Smtm route -n flush 56117019Smtm} 57117019Smtm 58117019Smtmstatic_start() 59117019Smtm{ 6051231Ssheldonh case ${defaultrouter} in 6151231Ssheldonh [Nn][Oo] | '') 6251231Ssheldonh ;; 6351231Ssheldonh *) 6451231Ssheldonh static_routes="default ${static_routes}" 6551231Ssheldonh route_default="default ${defaultrouter}" 6651231Ssheldonh ;; 6751231Ssheldonh esac 6840006Sphk 69100280Sgordon # Setup static routes. This should be done before router discovery. 7051231Ssheldonh # 7151231Ssheldonh if [ -n "${static_routes}" ]; then 7251231Ssheldonh for i in ${static_routes}; do 7351231Ssheldonh eval route_args=\$route_${i} 74117032Smtm route add ${route_args} 7551231Ssheldonh done 7651231Ssheldonh fi 77118908Sharti # Now ATM static routes 78118908Sharti # 79118908Sharti if [ -n "${natm_static_routes}" ]; then 80118908Sharti for i in ${natm_static_routes}; do 81118908Sharti eval route_args=\$route_${i} 82118908Sharti atmconfig natm add ${route_args} 83118908Sharti done 84118908Sharti fi 85117019Smtm} 8629300Sdanny 87117019Smtmoptions_start() 88117019Smtm{ 8951231Ssheldonh echo -n 'Additional routing options:' 9051231Ssheldonh case ${icmp_bmcastecho} in 9151231Ssheldonh [Yy][Ee][Ss]) 9251231Ssheldonh echo -n ' broadcast ping responses=YES' 9387646Sru sysctl net.inet.icmp.bmcastecho=1 >/dev/null 9451231Ssheldonh ;; 9551231Ssheldonh esac 9645096Simp 9751231Ssheldonh case ${icmp_drop_redirect} in 9851231Ssheldonh [Yy][Ee][Ss]) 9951231Ssheldonh echo -n ' ignore ICMP redirect=YES' 10087646Sru sysctl net.inet.icmp.drop_redirect=1 >/dev/null 10151231Ssheldonh ;; 10251231Ssheldonh esac 10339267Sjkoshy 10451231Ssheldonh case ${icmp_log_redirect} in 10551231Ssheldonh [Yy][Ee][Ss]) 10651231Ssheldonh echo -n ' log ICMP redirect=YES' 10787646Sru sysctl net.inet.icmp.log_redirect=1 >/dev/null 10851231Ssheldonh ;; 10951231Ssheldonh esac 11033439Sguido 11151231Ssheldonh case ${gateway_enable} in 11251231Ssheldonh [Yy][Ee][Ss]) 11351231Ssheldonh echo -n ' IP gateway=YES' 11487646Sru sysctl net.inet.ip.forwarding=1 >/dev/null 11551231Ssheldonh ;; 11651231Ssheldonh esac 11733439Sguido 11851231Ssheldonh case ${forward_sourceroute} in 11951231Ssheldonh [Yy][Ee][Ss]) 12051231Ssheldonh echo -n ' do source routing=YES' 12187646Sru sysctl net.inet.ip.sourceroute=1 >/dev/null 12251231Ssheldonh ;; 12351231Ssheldonh esac 12447752Sphk 12551231Ssheldonh case ${accept_sourceroute} in 12651231Ssheldonh [Yy][Ee][Ss]) 12751231Ssheldonh echo -n ' accept source routing=YES' 12887646Sru sysctl net.inet.ip.accept_sourceroute=1 >/dev/null 12951231Ssheldonh ;; 13051231Ssheldonh esac 13151209Sdes 13251231Ssheldonh case ${ipxgateway_enable} in 13351231Ssheldonh [Yy][Ee][Ss]) 13451231Ssheldonh echo -n ' IPX gateway=YES' 13587646Sru sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null 13651231Ssheldonh ;; 13751231Ssheldonh esac 13851231Ssheldonh 13951231Ssheldonh case ${arpproxy_all} in 14051231Ssheldonh [Yy][Ee][Ss]) 14151231Ssheldonh echo -n ' ARP proxyall=YES' 14287646Sru sysctl net.link.ether.inet.proxyall=1 >/dev/null 14351231Ssheldonh ;; 14451231Ssheldonh esac 14561961Sdillon 14651231Ssheldonh echo '.' 14725184Sjkh} 14825184Sjkh 149100280Sgordonload_rc_config $name 150100280Sgordonrun_rc_command "$1" 151