source: hybrid/branches/releng-9.0/nanobsd/files/etc/dhclient-exit-hooks@ 10720

Last change on this file since 10720 was 10651, checked in by rick, 13 years ago

Convert script to one compatible with shadow route table idea.

Related-To: nodefactory#129

  • Property svn:executable set to *
File size: 1.6 KB
Line 
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
10: ${service_proxy_normal="NO"}
11: ${service_proxy_ileiden="NO"}
12: ${service_accesspoint="NO"}
13
14load_rc_config 'ileiden'
15
16update_pf_conf() {
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
24 $LOGGER "Syncing new default route ($new_ext_if_gw) to routing table 1"
25 { grep -v '^ext_if_gw=' $rc_conf_running; echo "ext_if_gw=$new_ext_if_gw"; } > $rc_conf_running
26 $LOGGER "`setfib 1 route -q del default 2>&1`"
27 $LOGGER "`setfib 1 route -q add default $new_ext_if_gw 2>&1`"
28 fi
29 else
30 $LOGGER "is_default_interface: FALSE"
31 fi
32
33 # Make sure not to nuke the default route on an ileiden proxy,
34 # as it will rendering it usefull
35 checkyesno "service_proxy_ileiden" && return
36
37 if [ -n "$new_ext_if_gw" ] && checkyesno "service_proxy_normal" && checkyesno "service_accesspoint"; then
38 $LOGGER "Removing default route from routing table 0 as machine is marked as service_proxy AND service_accesspoint"
39 $LOGGER "`route -q del default 2>&1`"
40 fi
41}
42
43reason=${reason:-${REASON:-"BOUND"}}
44case $reason in
45 BOUND|RENEW|REBIND|REBOOT)
46 update_pf_conf
47 ;;
48 TIMEOUT)
49 update_pf_conf
50 ;;
51esac
52
Note: See TracBrowser for help on using the repository browser.