summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/routing/defaultroute.sh
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2012-01-04 13:09:05 +0100
committermakefu <github@syntax-fehler.de>2012-01-04 13:09:05 +0100
commita7f3e59a37f6b59738fe33d7e3d0953f8461f361 (patch)
treed83b4f994bf7ba54ed03ad674b336fab42bc4481 /retiolum/scripts/routing/defaultroute.sh
parentd67c6825b2d5f7ab6a66858fbe93194650ef57b2 (diff)
parent91d6fc8971483bf8e1fed7d649f966d180e23956 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/scripts/routing/defaultroute.sh')
-rwxr-xr-xretiolum/scripts/routing/defaultroute.sh16
1 files changed, 4 insertions, 12 deletions
diff --git a/retiolum/scripts/routing/defaultroute.sh b/retiolum/scripts/routing/defaultroute.sh
index a9e227a6..f5a1a465 100755
--- a/retiolum/scripts/routing/defaultroute.sh
+++ b/retiolum/scripts/routing/defaultroute.sh
@@ -7,7 +7,7 @@ usage()
echo "-d deactivate routing"
}
-defaultroute=$(route -n | grep 'UG[ \t]' | awk '{print $2}')
+defaultroute=$(ip route show | grep default | awk '{ print $3 }')
tincdir="/etc/tinc/retiolum"
if [[ $(id -u) -gt 0 ]]; then
@@ -30,17 +30,9 @@ case "$1" in
exit 1;;
esac
-
-cat $tincdir/hosts/* | grep Address | cut -b 11- |
+cat $tincdir/tinc.conf | grep ConnectTo | cut -b 13- |
while read host
do
- if [ "$(echo $host | sed 's/[0-9]*//g' | sed 's/\.//g')" = '' ]; then
- route $command $host gw $defaultroute
- else
- host -4 $host | grep "has address" | awk '{ print $4 }' |
- while read addr
- do
- route $command $addr gw $defaultroute && echo "$command routing to $addr via $defaultroute"
- done
- fi
+ addr=$(cat $tincdir/hosts/$host | grep Address | cut -b 11-)
+ echo route $command $addr gw $defaultroute
done