]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/routing
Add /usr/share/examples/bootforth so that world builds don't start falling
[FreeBSD/FreeBSD.git] / etc / rc.d / routing
1 #!/bin/sh -
2 #
3 #       $Id: rc.network,v 1.35 1998/11/15 20:30:04 msmith Exp $
4 #       From: @(#)netstart      5.9 (Berkeley) 3/30/91
5
6 # Note that almost all the user-configurable behavior is no longer in
7 # this file, but rather in /etc/rc.conf.  Please check that file
8 # first before contemplating any changes here.  If you do need to change
9 # this file for some reason, we would like to know about it.
10
11 # First pass startup stuff.
12
13 network_pass1() {
14     echo -n 'Doing initial network setup:'
15     # Set the host name if it is not already set
16     if [ -z "`hostname -s`" ] ; then
17             hostname $hostname
18             echo -n ' hostname'
19     fi
20
21     # Set the domainname if we're using NIS
22     if [ -n "$nisdomainname" -a "x$nisdomainname" != "xNO" ] ; then
23             domainname $nisdomainname
24             echo -n ' domain'
25     fi
26     echo '.'
27
28     # Initial ATM interface configuration
29     if [ "X${atm_enable}" = X"YES" -a -f /etc/rc.atm ]; then
30             . /etc/rc.atm
31             atm_pass1
32     fi
33
34     # Set up all the network interfaces, calling startup scripts if needed
35     for ifn in ${network_interfaces}; do
36             if [ -e /etc/start_if.${ifn} ]; then
37                     . /etc/start_if.${ifn}
38             fi
39             # Do the primary ifconfig if specified
40             eval ifconfig_args=\$ifconfig_${ifn}
41             if [ -n "${ifconfig_args}" ] ; then
42                     ifconfig ${ifn} ${ifconfig_args}
43             fi
44             # Check to see if aliases need to be added
45             alias=0
46             while :
47             do
48                     eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
49                     if [ -n "${ifconfig_args}" ]; then
50                             ifconfig ${ifn} ${ifconfig_args} alias
51                             alias=`expr ${alias} + 1`
52                     else
53                             break;
54                     fi
55             done
56             # Do ipx address if specified
57             eval ifconfig_args=\$ifconfig_${ifn}_ipx
58             if [ -n "${ifconfig_args}" ]; then
59                     ifconfig ${ifn} ${ifconfig_args}
60             fi
61             ifconfig ${ifn}
62     done
63
64     # Initialize IP filtering using ipfw
65     echo ""
66     /sbin/ipfw -q flush > /dev/null 2>&1
67     if [ $? = 0 ] ; then
68         firewall_in_kernel=1
69     else 
70         firewall_in_kernel=0
71     fi
72
73     if [ $firewall_in_kernel = 0 -a "x$firewall_enable"  = "xYES" ] ; then
74         if kldload ipfw; then
75                 firewall_in_kernel=1            # module loaded successfully
76                 echo "Kernel firewall module loaded."
77         else
78                 echo "Warning: firewall kernel module failed to load."
79         fi
80     fi
81
82     # Load the filters if required
83     if [ $firewall_in_kernel = 1 ]; then
84         if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \
85                 "x$firewall_enable" = "xYES" ] ; then
86             . /etc/rc.firewall
87             echo "Firewall rules loaded."
88         else
89             IPFW_DEFAULT=`ipfw l 65535`
90             if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then
91                 echo -n "Warning: kernel has firewall functionality, "
92                 echo "but firewall rules are not enabled."
93                 echo "         All ip services are disabled."
94             fi
95         fi
96     fi
97
98     # Additional ATM interface configuration
99     if [ -n "${atm_pass1_done}" ]; then
100             atm_pass2
101     fi
102
103     # Configure routing
104
105     if [ "x$defaultrouter" != "xNO" ] ; then
106             static_routes="default ${static_routes}"
107             route_default="default ${defaultrouter}"
108     fi
109     
110     # Set up any static routes.  This should be done before router discovery.
111     if [ "x${static_routes}" != "x" ]; then
112             for i in ${static_routes}; do
113                     eval route_args=\$route_${i}
114                     route add ${route_args}
115             done
116     fi
117
118     echo -n 'Additional routing options:'
119     if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then
120             echo -n ' tcp extensions=NO'
121             sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1
122     fi
123
124     if [ X"$icmp_bmcastecho" = X"YES" ]; then
125             echo -n ' broadcast ping responses=YES'
126             sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1
127     fi
128
129     if [ "X$gateway_enable" = X"YES" ]; then
130             echo -n ' IP gateway=YES'
131             sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1
132     fi
133     
134     if [ "X$forward_sourceroute" = X"YES" ]; then
135             echo -n ' do source routing=YES'
136             sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1
137     fi
138
139     if [ "X$accept_sourceroute" = X"YES" ]; then
140             echo -n ' accept source routing=YES'
141             sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1
142     fi
143
144     if [ "X$ipxgateway_enable" = X"YES" ]; then
145             echo -n ' IPX gateway=YES'
146             sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1
147     fi
148     
149     if [ "X$arpproxy_all" = X"YES" ]; then
150             echo -n ' enabling ARP_PROXY_ALL: '
151             sysctl -w net.link.ether.inet.proxyall=1 2>&1
152     fi
153     echo '.'
154
155     echo -n 'routing daemons:'
156     if [ "X$router_enable" = X"YES" ]; then
157             echo -n " ${router}";       ${router} ${router_flags}
158     fi
159     
160     if [ "X$ipxrouted_enable" = X"YES" ]; then
161             echo -n ' IPXrouted'
162             IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
163     fi
164     
165     if [ "X${mrouted_enable}" = X"YES" ]; then
166             echo -n ' mrouted'; mrouted ${mrouted_flags}
167     fi
168
169     if [ "X$rarpd_enable" = X"YES" ]; then
170             echo -n ' rarpd';     rarpd ${rarpd_flags}
171     fi
172     echo '.'
173     network_pass1_done=YES      # Let future generations know we made it.
174 }
175
176 network_pass2() {
177     echo -n 'Doing additional network setup:'
178     if [ "X${named_enable}" = X"YES" ]; then
179             echo -n ' named';           ${named_program-"named"} ${named_flags}
180     fi
181
182     if [ "X${ntpdate_enable}" = X"YES" ]; then
183             echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1
184     fi
185
186     if [ "X${xntpd_enable}" = X"YES" ]; then
187             echo -n ' xntpd';   ${xntpd_program} ${xntpd_flags}
188     fi
189
190     if [ "X${timed_enable}" = X"YES" ]; then
191             echo -n ' timed';           timed ${timed_flags}
192     fi
193
194     if [ "X${portmap_enable}" = X"YES" ]; then
195             echo -n ' portmap';         portmap ${portmap_flags}
196     fi
197
198     # Start ypserv if we're an NIS server.
199     # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
200     if [ "X${nis_server_enable}" = X"YES" ]; then
201             echo -n ' ypserv'; ypserv ${nis_server_flags}
202             
203             if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then
204                     echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags}
205             fi
206             
207             if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then
208                     echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags}
209             fi
210     fi
211
212     # Start ypbind if we're an NIS client
213     if [ "X${nis_client_enable}" = X"YES" ]; then
214             echo -n ' ypbind'; ypbind ${nis_client_flags}
215             if [ "X${nis_ypset_enable}" = X"YES" ]; then
216                     echo -n ' ypset'; ypset ${nis_ypset_flags}
217             fi
218     fi
219
220     # Start keyserv if we are running Secure RPC
221     if [ "X${keyserv_enable}" = X"YES" ]; then
222             echo -n ' keyserv';         keyserv ${keyserv_flags}
223     fi
224     # Start ypupdated if we are running Secure RPC and we are NIS master
225     if [ "X$rpc_ypupdated_enable" = X"YES" ]; then
226             echo -n ' rpc.ypupdated';   rpc.ypupdated
227     fi
228
229     # Start ATM daemons
230     if [ -n "${atm_pass2_done}" ]; then
231             atm_pass3
232     fi
233
234     echo '.'
235     network_pass2_done=YES
236 }
237
238 network_pass3() {
239     echo -n 'Starting final network daemons:'
240
241     if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then
242             echo -n ' mountd'
243             if [ "X${weak_mountd_authentication}" = X"YES" ]; then
244                     mountd_flags="-n"
245             fi
246             mountd ${mountd_flags}
247             if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
248                     sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1
249             fi
250             echo -n ' nfsd';            nfsd ${nfs_server_flags}
251             if [ "X$rpc_lockd_enable" = X"YES" ]; then
252                 echo -n ' rpc.lockd';           rpc.lockd
253             fi
254             if [ "X$rpc_statd_enable" = X"YES" ]; then
255                 echo -n ' rpc.statd';           rpc.statd
256             fi
257     fi
258     
259     if [ "X${nfs_client_enable}" = X"YES" ]; then
260             echo -n ' nfsiod';          nfsiod ${nfs_client_flags}
261             if [ "X${nfs_access_cache}" != X ]; then
262                 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
263                         >/dev/null 2>&1
264             fi
265     fi
266
267     if [ "X${amd_enable}" = X"YES" ]; then
268             echo -n ' amd'
269             if [ "X${amd_map_program}" != X"NO" ]; then
270                 amd_flags="${amd_flags} `eval ${amd_map_program}`"
271             fi
272             amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
273     fi
274
275     if [ "X${rwhod_enable}" = X"YES" ]; then
276             echo -n ' rwhod';   rwhod
277     fi
278
279     # Kerberos runs ONLY on the Kerberos server machine
280     if [ "X${kerberos_server_enable}" = X"YES" ]; then
281             if [ "X${kerberos_stash}" = "XYES" ]; then
282                 stash_flag=-n
283             else
284                 stash_flag=
285             fi
286             echo -n ' kerberos'; \
287                 kerberos ${stash_flag} >> /var/log/kerberos.log &
288             if [ "X${kadmind_server_enable}" = "XYES" ]; then
289                 echo -n ' kadmind'; \
290                 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
291             fi
292             unset stash_flag
293     fi
294     
295     # Network Address Translation daemon
296        if [ "X${natd_enable}" = X"YES" -a X"${natd_interface}" != X"" \
297                -a X"${firewall_enable}" = X"YES" ]; then
298                if echo ${natd_interface} | \
299                        grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
300                        natd_ifarg="-a ${natd_interface}"
301                else
302                        natd_ifarg="-n ${natd_interface}"
303                fi
304                echo -n ' natd'; natd ${natd_flags} ${natd_ifarg}
305        fi
306
307     echo '.'
308     network_pass3_done=YES
309 }