scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 52390b9bc4657a075e9e9db6ce222fda4cd967bd
parent 988509f076dbf5ea64e70c17f0211ded4d868a7d
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sun, 11 Dec 2016 16:43:42 +0100

[iwpick] Auto add the default gw.
Also, by clear the interface IP we ensure that the 1st packet received by tcpdump(1) is that we expect.

Diffstat:
Msrc/iwpick | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/iwpick b/src/iwpick @@ -12,7 +12,7 @@ connect() { echo "Connecting to ${essid}..." - ifconfig $iface up + ifconfig $iface up 0 iwconfig $iface essid $essid if [ -n "$key" ]; then @@ -23,8 +23,13 @@ connect() { fi sdhcp -d $iface >/dev/null & - addr="$(tcpdump -vlni $iface -c 1 -Q in udp 2>&1 |grep "Your-IP" |tr -d [:space:] |cut -b8-)" + pkt="$(tcpdump -vlni $iface -c 1 -Q in udp 2>&1)" + addr="$(echo "$pkt" |grep "Your-IP" |tr -d [:space:] |cut -b8-)" + dgw="$(echo "$pkt" |grep "Gateway-IP" |tr -d [:space:] |cut -b11-)" + egw="$(echo "$pkt" |grep "Default-Gateway" |tr -d [:space:] |cut -d: -f2)" + [ -n "$dgw" ] && gw="$dgw" || gw="$egw" ifconfig $iface $addr + route add default gw $gw } die() {