]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/routing
Pull in /etc/rc.conf.d/network so that ifconfig_<if> variables can be
[FreeBSD/FreeBSD.git] / etc / rc.d / routing
1 #!/bin/sh
2 #
3 # Configure routing and miscellaneous network tunables
4 #
5 # $FreeBSD$
6 #
7
8 # PROVIDE: routing
9 # REQUIRE: netif ppp
10 # KEYWORD: nojail
11
12 . /etc/rc.subr
13
14 name="routing"
15 start_cmd="routing_start"
16 stop_cmd="routing_stop"
17 extra_commands="options static"
18 static_cmd="static_start"
19 options_cmd="options_start"
20
21 routing_start()
22 {
23         static_start
24         options_start
25 }
26
27 routing_stop()
28 {
29         route -n flush
30 }
31
32 static_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
61 options_start()
62 {
63         echo -n 'Additional routing options:'
64         case ${tcp_extensions} in
65         [Yy][Ee][Ss] | '')
66                 ;;
67         *)
68                 echo -n ' tcp extensions=NO'
69                 sysctl net.inet.tcp.rfc1323=0 >/dev/null
70                 ;;
71         esac
72
73         case ${icmp_bmcastecho} in
74         [Yy][Ee][Ss])
75                 echo -n ' broadcast ping responses=YES'
76                 sysctl net.inet.icmp.bmcastecho=1 >/dev/null
77                 ;;
78         esac
79
80         case ${icmp_drop_redirect} in
81         [Yy][Ee][Ss])
82                 echo -n ' ignore ICMP redirect=YES'
83                 sysctl net.inet.icmp.drop_redirect=1 >/dev/null
84                 ;;
85         esac
86
87         case ${icmp_log_redirect} in
88         [Yy][Ee][Ss])
89                 echo -n ' log ICMP redirect=YES'
90                 sysctl net.inet.icmp.log_redirect=1 >/dev/null
91                 ;;
92         esac
93
94         case ${gateway_enable} in
95         [Yy][Ee][Ss])
96                 echo -n ' IP gateway=YES'
97                 sysctl net.inet.ip.forwarding=1 >/dev/null
98                 ;;
99         esac
100
101         case ${forward_sourceroute} in
102         [Yy][Ee][Ss])
103                 echo -n ' do source routing=YES'
104                 sysctl net.inet.ip.sourceroute=1 >/dev/null
105                 ;;
106         esac
107
108         case ${accept_sourceroute} in
109         [Yy][Ee][Ss])
110                 echo -n ' accept source routing=YES'
111                 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
112                 ;;
113         esac
114
115         case ${tcp_keepalive} in
116         [Nn][Oo])
117                 echo -n ' TCP keepalive=NO'
118                 sysctl net.inet.tcp.always_keepalive=0 >/dev/null
119                 ;;
120         esac
121
122         case ${tcp_drop_synfin} in
123         [Yy][Ee][Ss])
124                 echo -n ' drop SYN+FIN packets=YES'
125                 sysctl net.inet.tcp.drop_synfin=1 >/dev/null
126                 ;;
127         esac
128
129         case ${ipxgateway_enable} in
130         [Yy][Ee][Ss])
131                 echo -n ' IPX gateway=YES'
132                 sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
133                 ;;
134         esac
135
136         case ${arpproxy_all} in
137         [Yy][Ee][Ss])
138                 echo -n ' ARP proxyall=YES'
139                 sysctl net.link.ether.inet.proxyall=1 >/dev/null
140                 ;;
141         esac
142
143         case ${ip_portrange_first} in
144         [Nn][Oo] | '')
145                 ;;
146         *)
147                 echo -n " ip_portrange_first=$ip_portrange_first"
148                 sysctl net.inet.ip.portrange.first=$ip_portrange_first >/dev/null
149                 ;;
150         esac
151
152         case ${ip_portrange_last} in
153         [Nn][Oo] | '')
154                 ;;
155         *)
156                 echo -n " ip_portrange_last=$ip_portrange_last"
157                 sysctl net.inet.ip.portrange.last=$ip_portrange_last >/dev/null
158                 ;;
159         esac
160
161         echo '.'
162 }
163
164 load_rc_config $name
165 run_rc_command "$1"