1 | #!/bin/sh -
|
---|
2 | #
|
---|
3 | # An normal proxy should not have an defaultrouter configured, as all calls to
|
---|
4 | # the outside world are handled via PF redirects.
|
---|
5 | #
|
---|
6 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
7 |
|
---|
8 | # Little hack to load the available functions in case we are running this as an
|
---|
9 | # standalone script (for testing mostly).
|
---|
10 | if [ -z "$exit_status" ]; then
|
---|
11 | grep -v 'exit $exit_status' /sbin/dhclient-script | eval
|
---|
12 | fi
|
---|
13 |
|
---|
14 | . /etc/rc.subr
|
---|
15 |
|
---|
16 | : ${service_proxy_normal="NO"}
|
---|
17 | : ${service_proxy_ileiden="NO"}
|
---|
18 | : ${service_accesspoint="NO"}
|
---|
19 |
|
---|
20 | load_rc_config 'ileiden'
|
---|
21 |
|
---|
22 | update_pf_conf() {
|
---|
23 | $LOGGER "reason: $reason"
|
---|
24 | if is_default_interface 2>/dev/null; then
|
---|
25 | $LOGGER "is_default_interface: TRUE"
|
---|
26 | new_ext_if_gw=`route -n get default 2>/dev/null | awk '/gateway/ {print $2}'`
|
---|
27 | $LOGGER "prev default gateway: $ext_if_gw"
|
---|
28 | $LOGGER "curr default gateway: $new_ext_if_gw"
|
---|
29 | if [ -n "$new_ext_if_gw" -a "$new_ext_if_gw" != "$ext_if_gw" ]; then
|
---|
30 | $LOGGER "Reloading PF firewall to load new ext_if_gw=$new_ext_if_gw"
|
---|
31 | { grep -v '^ext_if_gw=' $rc_conf_running; echo "ext_if_gw=$new_ext_if_gw"; } > $rc_conf_running
|
---|
32 | $LOGGER "`/etc/rc.d/pf reload 2>&1`"
|
---|
33 | fi
|
---|
34 | else
|
---|
35 | $LOGGER "is_default_interface: FALSE"
|
---|
36 | fi
|
---|
37 |
|
---|
38 | # Make sure not to nuke the default route on an ileiden proxy,
|
---|
39 | # as it will rendering it usefull
|
---|
40 | checkyesno "service_proxy_ileiden" && return
|
---|
41 |
|
---|
42 | if [ -n "$new_ext_if_gw" ] && checkyesno "service_proxy_normal" && checkyesno "service_accesspoint"; then
|
---|
43 | $LOGGER "Removing default route as machine is marked as service_proxy AND service_accesspoint"
|
---|
44 | $LOGGER "`route -q del default 2>&1`"
|
---|
45 | fi
|
---|
46 | }
|
---|
47 |
|
---|
48 | reason=${reason:-${REASON:-"BOUND"}}
|
---|
49 | case $reason in
|
---|
50 | BOUND|RENEW|REBIND|REBOOT)
|
---|
51 | update_pf_conf
|
---|
52 | ;;
|
---|
53 | TIMEOUT)
|
---|
54 | update_pf_conf
|
---|
55 | ;;
|
---|
56 | esac
|
---|
57 |
|
---|