defaultroute revision 169217
1#!/bin/sh
2#
3# Configure routing and miscellaneous network tunables
4#
5# $FreeBSD: head/etc/rc.d/routing 169217 2007-05-02 15:49:30Z mtm $
6#
7
8# PROVIDE: routing
9# REQUIRE: netif ppp
10# KEYWORD: nojail
11
12. /etc/rc.subr
13
14name="routing"
15start_cmd="routing_start"
16stop_cmd="routing_stop"
17extra_commands="options static"
18static_cmd="static_start"
19options_cmd="options_start"
20
21routing_start()
22{
23	static_start
24	options_start
25}
26
27routing_stop()
28{
29	route -n flush
30}
31
32static_start()
33{
34	case ${defaultrouter} in
35	[Nn][Oo] | '')
36		;;
37	*)
38		static_routes="default ${static_routes}"
39		route_default="default ${defaultrouter}"
40		;;
41	esac
42
43	# Setup static routes. This should be done before router discovery.
44	#
45	if [ -n "${static_routes}" ]; then
46		for i in ${static_routes}; do
47			eval route_args=\$route_${i}
48			route add ${route_args}
49		done
50	fi
51	# Now ATM static routes
52	#
53	if [ -n "${natm_static_routes}" ]; then
54		for i in ${natm_static_routes}; do
55			eval route_args=\$route_${i}
56			atmconfig natm add ${route_args}
57		done
58	fi
59}
60
61options_start()
62{
63	echo -n 'Additional routing options:'
64	case ${icmp_bmcastecho} in
65	[Yy][Ee][Ss])
66		echo -n ' broadcast ping responses=YES'
67		sysctl net.inet.icmp.bmcastecho=1 >/dev/null
68		;;
69	esac
70
71	case ${icmp_drop_redirect} in
72	[Yy][Ee][Ss])
73		echo -n ' ignore ICMP redirect=YES'
74		sysctl net.inet.icmp.drop_redirect=1 >/dev/null
75		;;
76	esac
77
78	case ${icmp_log_redirect} in
79	[Yy][Ee][Ss])
80		echo -n ' log ICMP redirect=YES'
81		sysctl net.inet.icmp.log_redirect=1 >/dev/null
82		;;
83	esac
84
85	case ${gateway_enable} in
86	[Yy][Ee][Ss])
87		echo -n ' IP gateway=YES'
88		sysctl net.inet.ip.forwarding=1 >/dev/null
89		;;
90	esac
91
92	case ${forward_sourceroute} in
93	[Yy][Ee][Ss])
94		echo -n ' do source routing=YES'
95		sysctl net.inet.ip.sourceroute=1 >/dev/null
96		;;
97	esac
98
99	case ${accept_sourceroute} in
100	[Yy][Ee][Ss])
101		echo -n ' accept source routing=YES'
102		sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
103		;;
104	esac
105
106	case ${ipxgateway_enable} in
107	[Yy][Ee][Ss])
108		echo -n ' IPX gateway=YES'
109		sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
110		;;
111	esac
112
113	case ${arpproxy_all} in
114	[Yy][Ee][Ss])
115		echo -n ' ARP proxyall=YES'
116		sysctl net.link.ether.inet.proxyall=1 >/dev/null
117		;;
118	esac
119
120	echo '.'
121}
122
123load_rc_config $name
124run_rc_command "$1"
125