[10586] | 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 | . /etc/rc.subr
|
---|
| 9 |
|
---|
[10590] | 10 | : ${service_proxy_normal="NO"}
|
---|
[10594] | 11 | : ${service_proxy_ileiden="NO"}
|
---|
[10590] | 12 | : ${service_accesspoint="NO"}
|
---|
[10586] | 13 |
|
---|
| 14 | load_rc_config 'ileiden'
|
---|
| 15 |
|
---|
[10594] | 16 | update_pf_conf() {
|
---|
[10608] | 17 | $LOGGER "reason: $reason"
|
---|
| 18 | if is_default_interface 2>/dev/null; then
|
---|
| 19 | $LOGGER "is_default_interface: TRUE"
|
---|
| 20 | new_ext_if_gw=`route -n get default 2>/dev/null | awk '/gateway/ {print $2}'`
|
---|
| 21 | $LOGGER "prev default gateway: $ext_if_gw"
|
---|
| 22 | $LOGGER "curr default gateway: $new_ext_if_gw"
|
---|
| 23 | if [ -n "$new_ext_if_gw" -a "$new_ext_if_gw" != "$ext_if_gw" ]; then
|
---|
[10651] | 24 | $LOGGER "Syncing new default route ($new_ext_if_gw) to routing table 1"
|
---|
[10608] | 25 | { grep -v '^ext_if_gw=' $rc_conf_running; echo "ext_if_gw=$new_ext_if_gw"; } > $rc_conf_running
|
---|
[10651] | 26 | $LOGGER "`setfib 1 route -q del default 2>&1`"
|
---|
| 27 | $LOGGER "`setfib 1 route -q add default $new_ext_if_gw 2>&1`"
|
---|
[10598] | 28 | fi
|
---|
[10608] | 29 | else
|
---|
| 30 | $LOGGER "is_default_interface: FALSE"
|
---|
[10598] | 31 | fi
|
---|
| 32 |
|
---|
[10594] | 33 | # Make sure not to nuke the default route on an ileiden proxy,
|
---|
| 34 | # as it will rendering it usefull
|
---|
[10595] | 35 | checkyesno "service_proxy_ileiden" && return
|
---|
[10590] | 36 |
|
---|
[10608] | 37 | if [ -n "$new_ext_if_gw" ] && checkyesno "service_proxy_normal" && checkyesno "service_accesspoint"; then
|
---|
[10651] | 38 | $LOGGER "Removing default route from routing table 0 as machine is marked as service_proxy AND service_accesspoint"
|
---|
[10608] | 39 | $LOGGER "`route -q del default 2>&1`"
|
---|
[10590] | 40 | fi
|
---|
| 41 | }
|
---|
| 42 |
|
---|
[10608] | 43 | reason=${reason:-${REASON:-"BOUND"}}
|
---|
[10590] | 44 | case $reason in
|
---|
| 45 | BOUND|RENEW|REBIND|REBOOT)
|
---|
[10608] | 46 | update_pf_conf
|
---|
[10590] | 47 | ;;
|
---|
| 48 | TIMEOUT)
|
---|
| 49 | update_pf_conf
|
---|
| 50 | ;;
|
---|
| 51 | esac
|
---|
| 52 |
|
---|