]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - etc/rc.d/routing
Document SA-15:11.bind.
[FreeBSD/stable/8.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 . /etc/network.subr
14
15 name="routing"
16 start_cmd="routing_start"
17 stop_cmd="routing_stop"
18 extra_commands="options static"
19 static_cmd="static_start"
20 options_cmd="options_start"
21
22 routing_start()
23 {
24         static_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         # Now ATM static routes
53         #
54         if [ -n "${natm_static_routes}" ]; then
55                 for i in ${natm_static_routes}; do
56                         eval route_args=\$route_${i}
57                         atmconfig natm add ${route_args}
58                 done
59         fi
60
61         # Disallow "internal" addresses to appear on the wire if inet6
62         # is enabled.
63         if afexists inet6; then
64                 local fibs i
65
66                 # Get the number of FIBs supported.
67                 fibs=`sysctl -n net.fibs`
68                 : ${fibs:=1}
69
70                 # disallow "internal" addresses to appear on the wire
71                 route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
72                 route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
73                 i=1
74                 if test ${i} -lt ${fibs}; then
75                         printf "Also installing reject routes for FIBs"
76                         while test ${i} -lt ${fibs}; do
77                                 setfib -F ${i} route -q add -inet6 \
78                                     ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
79                                 setfib -F ${i} route -q add -inet6 \
80                                     ::0.0.0.0 -prefixlen 96 ::1 -reject
81                                 printf " %d" ${i}
82                                 i=$((i + 1))
83                         done
84                         printf "\n"
85                 fi
86         fi
87 }
88
89 _ropts_initdone=
90 ropts_init()
91 {
92         if [ -z "${_ropts_initdone}" ]; then
93                 echo -n 'Additional routing options:'
94                 _ropts_initdone=yes
95         fi
96 }
97
98 options_start()
99 {
100         case ${icmp_bmcastecho} in
101         [Yy][Ee][Ss])
102                 ropts_init
103                 echo -n ' broadcast ping responses=YES'
104                 sysctl net.inet.icmp.bmcastecho=1 >/dev/null
105                 ;;
106         esac
107
108         case ${icmp_drop_redirect} in
109         [Yy][Ee][Ss])
110                 ropts_init
111                 echo -n ' ignore ICMP redirect=YES'
112                 sysctl net.inet.icmp.drop_redirect=1 >/dev/null
113                 ;;
114         esac
115
116         case ${icmp_log_redirect} in
117         [Yy][Ee][Ss])
118                 ropts_init
119                 echo -n ' log ICMP redirect=YES'
120                 sysctl net.inet.icmp.log_redirect=1 >/dev/null
121                 ;;
122         esac
123
124         case ${gateway_enable} in
125         [Yy][Ee][Ss])
126                 ropts_init
127                 echo -n ' IP gateway=YES'
128                 sysctl net.inet.ip.forwarding=1 >/dev/null
129                 ;;
130         esac
131
132         case ${forward_sourceroute} in
133         [Yy][Ee][Ss])
134                 ropts_init
135                 echo -n ' do source routing=YES'
136                 sysctl net.inet.ip.sourceroute=1 >/dev/null
137                 ;;
138         esac
139
140         case ${accept_sourceroute} in
141         [Yy][Ee][Ss])
142                 ropts_init
143                 echo -n ' accept source routing=YES'
144                 sysctl net.inet.ip.accept_sourceroute=1 >/dev/null
145                 ;;
146         esac
147
148         case ${ipxgateway_enable} in
149         [Yy][Ee][Ss])
150                 ropts_init
151                 echo -n ' IPX gateway=YES'
152                 sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null
153                 ;;
154         esac
155
156         case ${arpproxy_all} in
157         [Yy][Ee][Ss])
158                 ropts_init
159                 echo -n ' ARP proxyall=YES'
160                 sysctl net.link.ether.inet.proxyall=1 >/dev/null
161                 ;;
162         esac
163
164          [ -n "${_ropts_initdone}" ] && echo '.'
165 }
166
167 load_rc_config $name
168 run_rc_command "$1"