diff options
-rw-r--r-- | etc/inc/interfaces.inc | 9 | ||||
-rwxr-xr-x | sbin/dhclient-script | 53 | ||||
-rwxr-xr-x | usr/local/sbin/ppp-linkup | 22 |
3 files changed, 61 insertions, 23 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index b16368e..fd0c5b8 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1029,6 +1029,13 @@ EOD; /* fire up mpd */ mwexec("/usr/local/sbin/mpd -b -d {$g['varetc_path']} -p {$g['varrun_path']}/mpd.pid pppoe"); + /* sleep until wan is up */ + while(!file_exists("{$g['tmp_path']}/wanup")) { + sleep(1); + } + unlink_if_exists("{$g['tmp_path']}/wanup"); + + return 0; } @@ -1346,4 +1353,4 @@ function discover_bridge($interface1, $interface2) { return "-1"; } -?>
\ No newline at end of file +?> diff --git a/sbin/dhclient-script b/sbin/dhclient-script index 89a00a0..e4f7f47 100755 --- a/sbin/dhclient-script +++ b/sbin/dhclient-script @@ -94,12 +94,16 @@ add_new_alias() { delete_old_routes() { $ROUTE delete "$old_ip_address" $LOCALHOST >/dev/null 2>&1 - for router in $old_routers; do - if [ $if_defaultroute = x -o $if_defaultroute = $interface ]; then - $ROUTE delete default $route >/dev/null 2>&1 - /bin/rm -f /tmp/${interface}_router - fi - done + # Only allow the default route to be overridden if it's on our own interface + DEFAULTROUTE_IFACE=`route get default | grep interface | awk '{print $2};'` + if [ -z "${DEFAULTROUTE_IFACE}" -o "{$interface}" = "${DEFAULTROUTE_IFACE}" ]; then + for router in $old_routers; do + if [ $if_defaultroute = x -o $if_defaultroute = $interface ]; then + $ROUTE delete default $route >/dev/null 2>&1 + /bin/rm -f /tmp/${interface}_router + fi + done + fi if [ -n "$old_static_routes" ]; then set $old_static_routes @@ -115,22 +119,27 @@ delete_old_routes() { add_new_routes() { $ROUTE add $new_ip_address $LOCALHOST >/dev/null 2>&1 - for router in $new_routers; do - if [ "$new_ip_address" = "$router" ]; then - $ROUTE add default -iface $router - #>/dev/null 2>&1 - echo $ROUTE add default -iface $router | $LOGGER - echo $new_routers > /tmp/${interface}_router - else - $ROUTE add default $router - echo $ROUTE add default $router | $LOGGER - #>/dev/null 2>&1 - echo $new_routers > /tmp/${interface}_router - fi - # 2nd and subsequent default routers error out, so explicitly - # stop processing the list after the first one. - break - done + + # Only allow the default route to be overridden if it's on our own interface + DEFAULTROUTE_IFACE=`route get default | grep interface | awk '{print $2};'` + if [ -z "${DEFAULTROUTE_IFACE}" -o "{$interface}" = "${DEFAULTROUTE_IFACE}" ]; then + for router in $new_routers; do + if [ "$new_ip_address" = "$router" ]; then + $ROUTE add default -iface $router + #>/dev/null 2>&1 + echo $ROUTE add default -iface $router | $LOGGER + echo $new_routers > /tmp/${interface}_router + else + $ROUTE add default $router + echo $ROUTE add default $router | $LOGGER + #>/dev/null 2>&1 + echo $new_routers > /tmp/${interface}_router + fi + # 2nd and subsequent default routers error out, so explicitly + # stop processing the list after the first one. + break + done + fi if [ -n "$new_static_routes" ]; then $LOGGER "New Static Routes ($interface): $new_static_routes" diff --git a/usr/local/sbin/ppp-linkup b/usr/local/sbin/ppp-linkup new file mode 100755 index 0000000..da43796 --- /dev/null +++ b/usr/local/sbin/ppp-linkup @@ -0,0 +1,22 @@ +#!/bin/sh + +rm -f /var/etc/nameservers.conf + +# unset CGI environment variables so as not to confuse PHP +unset CONTENT_TYPE GATEWAY_INTERFACE REMOTE_USER REMOTE_ADDR AUTH_TYPE +unset HTTP_USER_AGENT CONTENT_LENGTH SCRIPT_FILENAME HTTP_HOST +unset SERVER_SOFTWARE HTTP_REFERER SERVER_PROTOCOL REQUEST_METHOD +unset SERVER_PORT SCRIPT_NAME SERVER_NAME + +# write nameservers to file +if [ "$6" = "dns1" ]; then + echo $7 >> /var/etc/nameservers.conf +fi +if [ "$8" = "dns2" ]; then + echo $9 >> /var/etc/nameservers.conf +fi + +# let the configuration system know that the +# WAN IP address has changed +/etc/rc.newwanip + |