82b4d9dcaeae692ed89e941b5208b3245bebd7b3
[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 #
7
8 # PROVIDE: routing
9 # REQUIRE: netif ppp-user
10
11 . /etc/rc.subr
12
13 name="routing"
14 start_cmd="routing_start"
15 stop_cmd="routing_stop"
16 extra_commands="options static change"
17 static_cmd="static_start"
18 change_cmd="change_start"
19 options_cmd="options_start"
20
21 routing_start()
22 {
23         static_start
24         change_start
25         options_start
26 }
27
28 routing_stop()
29 {
30         route -n flush
31 }
32
33 static_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 }
53
54 change_start()
55 {
56         # Change routes. This should be done before router discovery.
57         #
58         if [ -n "${change_routes}" ]; then
59                 for i in ${change_routes}; do
60                         eval route_args=\$change_route_${i}
61                         route change ${route_args}
62                 done
63         fi
64 }
65
66 options_start()
67 {
68         echo -n 'Additional routing options:'
69         case ${tcp_extensions} in
70         [Yy][Ee][Ss] | '')
71                 ;;
72         *)
73                 echo -n ' tcp extensions=NO'
74                 sysctl net.inet.tcp.rfc1323=0 >/dev/null
75                 ;;
76         esac
77
78         case ${icmp_bmcastecho} in
79         [Yy][Ee][Ss])
80                 echo -n ' broadcast ping responses=YES'
81                 sysctl net.inet.icmp.bmcastecho=1 >/dev/null
82                 ;;
83         esac
84
85         case ${icmp_drop_redirect} in
86         [Yy][Ee][Ss])
87                 echo -n ' ignore ICMP redirect=YES'
88                 sysctl net.inet.icmp.drop_redirect=1 >/dev/null
89                 ;;
90         esac
91
92         case ${icmp_log_redirect} in
93         [Yy][Ee][Ss])
94                 echo -n ' log ICMP redirect=YES'
95                 sysctl net.inet.icmp.log_redirect=1 >/dev/null
96                 ;;
97         esac
98
99         case ${gateway_enable} in
100         [Yy][Ee][Ss])
101                 echo -n ' IP gateway=YES'
102                 sysctl net.inet.ip.forwarding=1 >/dev/null
103                 ;;
104         esac
105
106         case ${forward_sourceroute} in
107         [Yy][Ee][Ss])
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                 echo -n ' accept source routing=YES'
116                 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
117                 ;;
118         esac
119
120         case ${tcp_keepalive} in
121         [Nn][Oo])
122                 echo -n ' TCP keepalive=NO'
123                 sysctl net.inet.tcp.always_keepalive=0 >/dev/null
124                 ;;
125         esac
126
127         case ${tcp_drop_synfin} in
128         [Yy][Ee][Ss])
129                 echo -n ' drop SYN+FIN packets=YES'
130                 sysctl net.inet.tcp.drop_synfin=1 >/dev/null
131                 ;;
132         esac
133
134         case ${arpproxy_all} in
135         [Yy][Ee][Ss])
136                 echo -n ' ARP proxyall=YES'
137                 sysctl net.link.ether.inet.proxyall=1 >/dev/null
138                 ;;
139         esac
140
141         case ${ip_portrange_first} in
142         [Nn][Oo] | '')
143                 ;;
144         *)
145                 echo -n " ip_portrange_first=$ip_portrange_first"
146                 sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
147                 ;;
148         esac
149
150         case ${ip_portrange_last} in
151         [Nn][Oo] | '')
152                 ;;
153         *)
154                 echo -n " ip_portrange_last=$ip_portrange_last"
155                 sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
156                 ;;
157         esac
158
159         echo '.'
160 }
161
162 load_rc_config $name
163 run_rc_command "$1"