79de961e31dc894762cd6be47291aebe0d0927ac
[dragonfly.git] / etc / rc.d / routing
1 #!/bin/sh
2 #
3 # Configure routing and miscellaneous network tunables
4 #
5 # $FreeBSD: src/etc/rc.d/routing,v 1.138 2003/06/29 17:59:09 mtm Exp $
6 # $DragonFly: src/etc/rc.d/routing,v 1.3 2005/11/19 21:47:32 swildner Exp $
7 #
8
9 # PROVIDE: routing
10 # REQUIRE: netif ppp-user
11
12 . /etc/rc.subr
13
14 name="routing"
15 start_cmd="routing_start"
16 stop_cmd="routing_stop"
17 extra_commands="options static change"
18 static_cmd="static_start"
19 change_cmd="change_start"
20 options_cmd="options_start"
21
22 routing_start()
23 {
24         static_start
25         change_start
26         options_start
27 }
28
29 routing_stop()
30 {
31         route -n flush
32 }
33
34 static_start()
35 {
36         case ${defaultrouter} in
37         [Nn][Oo] | '')
38                 ;;
39         *)
40                 static_routes="default ${static_routes}"
41                 route_default="default ${defaultrouter}"
42                 ;;
43         esac
44
45         # Setup static routes. This should be done before router discovery.
46         #
47         if [ -n "${static_routes}" ]; then
48                 for i in ${static_routes}; do
49                         eval route_args=\$route_${i}
50                         route add ${route_args}
51                 done
52         fi
53 }
54
55 change_start()
56 {
57         # Change routes. This should be done before router discovery.
58         #
59         if [ -n "${change_routes}" ]; then
60                 for i in ${change_routes}; do
61                         eval route_args=\$change_route_${i}
62                         route change ${route_args}
63                 done
64         fi
65 }
66
67 options_start()
68 {
69         echo -n 'Additional routing options:'
70         case ${tcp_extensions} in
71         [Yy][Ee][Ss] | '')
72                 ;;
73         *)
74                 echo -n ' tcp extensions=NO'
75                 sysctl net.inet.tcp.rfc1323=0 >/dev/null
76                 ;;
77         esac
78
79         case ${icmp_bmcastecho} in
80         [Yy][Ee][Ss])
81                 echo -n ' broadcast ping responses=YES'
82                 sysctl net.inet.icmp.bmcastecho=1 >/dev/null
83                 ;;
84         esac
85
86         case ${icmp_drop_redirect} in
87         [Yy][Ee][Ss])
88                 echo -n ' ignore ICMP redirect=YES'
89                 sysctl net.inet.icmp.drop_redirect=1 >/dev/null
90                 ;;
91         esac
92
93         case ${icmp_log_redirect} in
94         [Yy][Ee][Ss])
95                 echo -n ' log ICMP redirect=YES'
96                 sysctl net.inet.icmp.log_redirect=1 >/dev/null
97                 ;;
98         esac
99
100         case ${gateway_enable} in
101         [Yy][Ee][Ss])
102                 echo -n ' IP gateway=YES'
103                 sysctl net.inet.ip.forwarding=1 >/dev/null
104                 ;;
105         esac
106
107         case ${forward_sourceroute} in
108         [Yy][Ee][Ss])
109                 echo -n ' do source routing=YES'
110                 sysctl net.inet.ip.sourceroute=1 >/dev/null
111                 ;;
112         esac
113
114         case ${accept_sourceroute} in
115         [Yy][Ee][Ss])
116                 echo -n ' accept source routing=YES'
117                 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
118                 ;;
119         esac
120
121         case ${tcp_keepalive} in
122         [Nn][Oo])
123                 echo -n ' TCP keepalive=NO'
124                 sysctl net.inet.tcp.always_keepalive=0 >/dev/null
125                 ;;
126         esac
127
128         case ${tcp_drop_synfin} in
129         [Yy][Ee][Ss])
130                 echo -n ' drop SYN+FIN packets=YES'
131                 sysctl net.inet.tcp.drop_synfin=1 >/dev/null
132                 ;;
133         esac
134
135         case ${ipxgateway_enable} in
136         [Yy][Ee][Ss])
137                 echo -n ' IPX gateway=YES'
138                 sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
139                 ;;
140         esac
141
142         case ${arpproxy_all} in
143         [Yy][Ee][Ss])
144                 echo -n ' ARP proxyall=YES'
145                 sysctl net.link.ether.inet.proxyall=1 >/dev/null
146                 ;;
147         esac
148
149         case ${ip_portrange_first} in
150         [Nn][Oo] | '')
151                 ;;
152         *)
153                 echo -n " ip_portrange_first=$ip_portrange_first"
154                 sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
155                 ;;
156         esac
157
158         case ${ip_portrange_last} in
159         [Nn][Oo] | '')
160                 ;;
161         *)
162                 echo -n " ip_portrange_last=$ip_portrange_last"
163                 sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
164                 ;;
165         esac
166
167         echo '.'
168 }
169
170 load_rc_config $name
171 run_rc_command "$1"