eremos
Senior Member
Still so confusing.. Everything that seems to work perfectly on my end seems to fail in fun and interesting ways on yours.
Here's a script you can run from the command line. It should still log to iplocal, routes, routes1 and routes2, but if there are any syntax or awk errors they should show up on the command line. It assumes your routefile.txt is in /tmp/
It will also fail to create the routes, as the IPREMOTE address is bogus. But it should give us an idea of what's happening
execute by running from the command line (and assuming script is called localroute):
sh localroute
Here's a script you can run from the command line. It should still log to iplocal, routes, routes1 and routes2, but if there are any syntax or awk errors they should show up on the command line. It assumes your routefile.txt is in /tmp/
It will also fail to create the routes, as the IPREMOTE address is bogus. But it should give us an idea of what's happening
execute by running from the command line (and assuming script is called localroute):
sh localroute
Code:
#!/bin/sh
IPLOCAL=196.1.1.1
IPREMOTE=1.1.1.1
case $IPLOCAL in
196.*)
echo local: $IPLOCAL >/tmp/iplocal.txt;
echo remote: $IPREMOTE >>/tmp/iplocal.txt;
rm /tmp/routes.log
# route add route-server.is.co.za gw $IPREMOTE;
# echo -e "terminal length 0\nshow ip bgp\nexit" | nc route-server.is.co.za 23 | grep ^* | awk '{print $2}' > /tmp/routefile.txt;
for i in `cat /tmp/routefile.txt | dos2unix`; do
if [[ $i =~ "/32" ]]; then echo 1: $i - route add -host $i gw $IPREMOTE >> /tmp/routes.log; route add -host $i gw $IPREMOTE >> /tmp/routes.log 2>&1;
else if [[ $i =~ "/" ]]; then echo 2: $i - route add -net $i gw $IPREMOTE >> /tmp/routes.log; route add -net $i gw $IPREMOTE >> /tmp/routes.log 2>&1;
else echo 3: $i - route add -net `echo -n $i | awk '{FS="." ; if ($1 >= 1 && $1 <= 126) {printf $0"/8"}else if ($1 >= 128 && $1 <= 191){printf $0"/16"}else if ($1 >= 192 && $1 <= 223){printf $0"/24"} }'` gw $IPREMOTE >> /tmp/routes.log; route add -net `echo -n $i | awk '{FS="." ; if ($1 >= 1 && $1 <= 126) {printf $0"/8"}else if ($1 >= 128 && $1 <= 191){printf $0"/16"}else if ($1 >= 192 && $1 <= 223){printf $0"/24"} }'` gw $IPREMOTE >> /tmp/routes.log 2>&1;
fi;
fi;
done;
;;
41.*)
echo $PPP_LOCAL >/etc/ppp/ipint.txt
;;
165.*)
echo $PPP_LOCAL >/etc/ppp/ipint.txt
;;
esac
Last edited: