routing revision 180563
1#!/bin/sh
2#
3# Configure routing and miscellaneous network tunables
4#
5# $FreeBSD: head/etc/rc.d/routing 180563 2008-07-16 19:22:48Z dougb $
6#
7
8# PROVIDE: routing
9# REQUIRE: 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
28routing_stop()
29{
30	route -n flush
31}
32
33static_start()
34{
35	case ${defaultrouter} in
36	[Nn][Oo] | '')
37		;;
38	*)
39		static_routes="default ${static_routes}"
40		route_default="default ${defaultrouter}"
41		;;
42	esac
43
44	# Setup static routes. This should be done before router discovery.
45	#
46	if [ -n "${static_routes}" ]; then
47		for i in ${static_routes}; do
48			eval route_args=\$route_${i}
49			route add ${route_args}
50		done
51	fi
52	# Now ATM static routes
53	#
54	if [ -n "${natm_static_routes}" ]; then
55		for i in ${natm_static_routes}; do
56			eval route_args=\$route_${i}
57			atmconfig natm add ${route_args}
58		done
59	fi
60}
61
62_ropts_initdone=
63ropts_init()
64{
65	if [ -z "${_ropts_initdone}" ]; then
66		echo -n 'Additional routing options:'
67		_ropts_initdone=yes
68	fi
69}
70
71options_start()
72{
73	case ${icmp_bmcastecho} in
74	[Yy][Ee][Ss])
75		ropts_init
76		echo -n ' broadcast ping responses=YES'
77		sysctl net.inet.icmp.bmcastecho=1 >/dev/null
78		;;
79	esac
80
81	case ${icmp_drop_redirect} in
82	[Yy][Ee][Ss])
83		ropts_init
84		echo -n ' ignore ICMP redirect=YES'
85		sysctl net.inet.icmp.drop_redirect=1 >/dev/null
86		;;
87	esac
88
89	case ${icmp_log_redirect} in
90	[Yy][Ee][Ss])
91		ropts_init
92		echo -n ' log ICMP redirect=YES'
93		sysctl net.inet.icmp.log_redirect=1 >/dev/null
94		;;
95	esac
96
97	case ${gateway_enable} in
98	[Yy][Ee][Ss])
99		ropts_init
100		echo -n ' IP gateway=YES'
101		sysctl net.inet.ip.forwarding=1 >/dev/null
102		;;
103	esac
104
105	case ${forward_sourceroute} in
106	[Yy][Ee][Ss])
107		ropts_init
108		echo -n ' do source routing=YES'
109		sysctl net.inet.ip.sourceroute=1 >/dev/null
110		;;
111	esac
112
113	case ${accept_sourceroute} in
114	[Yy][Ee][Ss])
115		ropts_init
116		echo -n ' accept source routing=YES'
117		sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
118		;;
119	esac
120
121	case ${ipxgateway_enable} in
122	[Yy][Ee][Ss])
123		ropts_init
124		echo -n ' IPX gateway=YES'
125		sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
126		;;
127	esac
128
129	case ${arpproxy_all} in
130	[Yy][Ee][Ss])
131		ropts_init
132		echo -n ' ARP proxyall=YES'
133		sysctl net.link.ether.inet.proxyall=1 >/dev/null
134		;;
135	esac
136
137	 [ -n "${_ropts_initdone}" ] && echo '.'
138}
139
140load_rc_config $name
141run_rc_command "$1"
142