List Info

Thread: default route deleted incorrectly with dhclient




default route deleted incorrectly with dhclient
user name
2006-07-20 15:27:57
In article <20060719225129.cc3858af.smbcs.columbia.edu>,
Steven M. Bellovin <smbcs.columbia.edu> wrote:
>A while back, I posted a note about the wrong default
route being deleted
>with dhclient.  Specifically, if I have a lease on int0,
suspend my
>laptop, and get a lease on int1 instead, when int0's
lease expires the
>default route -- via int1 -- will be deleted.
>
>Here's a patch that's currently in my
/etc/dhclient-enter-hooks, but could
>(or should) go into /sbin/dhclient-script instead.  How
does it look?  (It
>would replace the current text of the
delete_old_routes() function.)
>
>
>delete_default() {
>        route show -inet | sed 1,4d | \
>        while read dest gw flags
>        do
>                if [ "$dest" = default -a
"$gw" = "$1" ]
>                then
>                        route delete -inet $dest $gw
>                        echo route delete -inet $dest
$gw >&2
>                fi
>        done
>}
>
>delete_old_routes() {
>        for router in $old_routers; do
>                delete_default "$router"
>        done >/dev/null 2>&1
>
>        set -- $old_static_routes
>        while [ $# -gt 1 ]; do
>                route delete $1 $2
>                shift; shift
>        done
>
>        arp -n -a | sed -n -e 's/^.*(\(.*\)) at
.*$/arp -n -d \1/p' | sh
>}
>
>

I don't get it. Isn't the old code and the new code
equivalent? I.e.
Instead of calling:

	route delete default "$router"

you call the new function

	delete_default "$router"

which does the same if it finds that this route exists...

christos

default route deleted incorrectly with dhclient
user name
2006-07-20 15:27:57
In article <20060719225129.cc3858af.smbcs.columbia.edu>,
Steven M. Bellovin <smbcs.columbia.edu> wrote:
>A while back, I posted a note about the wrong default
route being deleted
>with dhclient.  Specifically, if I have a lease on int0,
suspend my
>laptop, and get a lease on int1 instead, when int0's
lease expires the
>default route -- via int1 -- will be deleted.
>
>Here's a patch that's currently in my
/etc/dhclient-enter-hooks, but could
>(or should) go into /sbin/dhclient-script instead.  How
does it look?  (It
>would replace the current text of the
delete_old_routes() function.)
>
>
>delete_default() {
>        route show -inet | sed 1,4d | \
>        while read dest gw flags
>        do
>                if [ "$dest" = default -a
"$gw" = "$1" ]
>                then
>                        route delete -inet $dest $gw
>                        echo route delete -inet $dest
$gw >&2
>                fi
>        done
>}
>
>delete_old_routes() {
>        for router in $old_routers; do
>                delete_default "$router"
>        done >/dev/null 2>&1
>
>        set -- $old_static_routes
>        while [ $# -gt 1 ]; do
>                route delete $1 $2
>                shift; shift
>        done
>
>        arp -n -a | sed -n -e 's/^.*(\(.*\)) at
.*$/arp -n -d \1/p' | sh
>}
>
>

I don't get it. Isn't the old code and the new code
equivalent? I.e.
Instead of calling:

	route delete default "$router"

you call the new function

	delete_default "$router"

which does the same if it finds that this route exists...

christos

default route deleted incorrectly with dhclient
user name
2006-07-20 15:27:57
In article <20060719225129.cc3858af.smbcs.columbia.edu>,
Steven M. Bellovin <smbcs.columbia.edu> wrote:
>A while back, I posted a note about the wrong default
route being deleted
>with dhclient.  Specifically, if I have a lease on int0,
suspend my
>laptop, and get a lease on int1 instead, when int0's
lease expires the
>default route -- via int1 -- will be deleted.
>
>Here's a patch that's currently in my
/etc/dhclient-enter-hooks, but could
>(or should) go into /sbin/dhclient-script instead.  How
does it look?  (It
>would replace the current text of the
delete_old_routes() function.)
>
>
>delete_default() {
>        route show -inet | sed 1,4d | \
>        while read dest gw flags
>        do
>                if [ "$dest" = default -a
"$gw" = "$1" ]
>                then
>                        route delete -inet $dest $gw
>                        echo route delete -inet $dest
$gw >&2
>                fi
>        done
>}
>
>delete_old_routes() {
>        for router in $old_routers; do
>                delete_default "$router"
>        done >/dev/null 2>&1
>
>        set -- $old_static_routes
>        while [ $# -gt 1 ]; do
>                route delete $1 $2
>                shift; shift
>        done
>
>        arp -n -a | sed -n -e 's/^.*(\(.*\)) at
.*$/arp -n -d \1/p' | sh
>}
>
>

I don't get it. Isn't the old code and the new code
equivalent? I.e.
Instead of calling:

	route delete default "$router"

you call the new function

	delete_default "$router"

which does the same if it finds that this route exists...

christos

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )