Linux routing help needed

lp, do this:

type route -n and you'll see a line like this:

Code:
196.209.16.1    0.0.0.0         255.255.255.255 UH    0      0        0 ppp0

that first IP is your gateway. so type:

Code:
for i in `cat /etc/ppp/routefile.txt | dos2unix` ; do if [[ $i =~ "/32" ]]; then echo route add -host $i gw 196.209.16.1; route add -host $i gw 196.209.16.1 ; fi ; done

The only changes I've made from the script you posted is to remove the logging to file and manually specifying the gateway, which you should adapt if necessary (in both instances)

you should see this:

Code:
route add -host 160.123.6.72/32 gw 196.209.16.1
route add -host 160.123.100.150/32 gw 196.209.16.1
route add -host 160.123.100.170/32 gw 196.209.16.1
route add -host 160.123.100.173/32 gw 196.209.16.1
route add -host 160.123.100.174/32 gw 196.209.16.1
route add -host 163.195.16.25/32 gw 196.209.16.1
route add -host 163.195.16.155/32 gw 196.209.16.1
route add -host 164.147.241.195/32 gw 196.209.16.1
route add -host 196.14.176.115/32 gw 196.209.16.1
route add -host 196.14.239.59/32 gw 196.209.16.1
route add -host 196.23.48.244/32 gw 196.209.16.1
route add -host 196.23.48.245/32 gw 196.209.16.1
route add -host 196.34.16.71/32 gw 196.209.16.1
route add -host 196.36.40.218/32 gw 196.209.16.1

route doesn't output anything if the command was successful.

e

edit: by the way, that should all be entered on command line. we want to see output.
 
Last edited:
yep that worked :)

exactly the output u had, only the ips with /32

checked routes and they're all there.
 
Ok so i think i made progress! :)

but i think now the routes get setup and then default route or something overwrites it, so international is trying to access via local?

Code:
196.34.0.0      196.209.64.1    255.254.0.0     UG    0      0        0 ppp0
163.202.0.0     196.209.64.1    255.254.0.0     UG    0      0        0 ppp0
164.146.0.0     196.209.64.1    255.254.0.0     UG    0      0        0 ppp0
196.208.0.0     196.209.64.1    255.252.0.0     UG    0      0        0 ppp0
164.148.0.0     196.209.64.1    255.252.0.0     UG    0      0        0 ppp0
41.240.0.0      196.209.64.1    255.248.0.0     UG    0      0        0 ppp0
10.0.0.0        196.209.64.1    255.0.0.0       UG    0      0        0 ppp0
0.0.0.0         196.209.64.1    0.0.0.0         UG    0      0        0 ppp1
0.0.0.0         196.209.64.1    0.0.0.0         UG    0      0        0 ppp0
and ifconfig:
Code:
ppp0      Link encap:Point-to-Point Protocol
          inet addr:196.209.69.147  P-t-P:196.209.64.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:586 errors:0 dropped:0 overruns:0 frame:0
          TX packets:655 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:510664 (498.6 KiB)  TX bytes:152183 (148.6 KiB)

ppp1      Link encap:Point-to-Point Protocol
          inet addr:196.209.66.214  P-t-P:196.209.64.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:83 errors:0 dropped:0 overruns:0 frame:0
          TX packets:107 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:31095 (30.3 KiB)  TX bytes:21129 (20.6 KiB)

any ideas?
 
lp, I've just made a couple of mods to the script you posted, and it seems to work on my system. changes are:

replacing PPP_LOCAL and PPP_GATEWAY with IPLOCAL and IPREMOTE instead
all instances of gw $PPP_LOCAL changed to gw $IPREMOTE
added the spaces mentioned before

Code:
case $IPLOCAL in
196.*)
        echo $IPLOCAL >/etc/ppp/iplocal.txt
#        route add route-server.is.co.za gw $IPREMOTE;
        echo /32 routes go here > /etc/ppp/routes.log
        echo other routes go here > /etc/ppp/routes1.log
        echo no / routes go here > /etc/ppp/routes2.log
        for i in `cat /etc/ppp/routefile.txt | dos2unix` ;
                do if [[ $i =~ "/32" ]]; then echo route add -host $i gw $IPREMOTE >> /etc/ppp/routes.log; route add -host $i gw $IPREMOTE >> /etc/ppp/routes.log 2>&1;
                else if [[ $i =~ "/" ]]; then echo route add -net $i gw $IPREMOTE >> /etc/ppp/routes1.log; route add -net $i gw $IPREMOTE >> /etc/ppp/routes1.log 2>&1;
                        else echo route add -net `echo -n $i | grep -v "/" | awk '{FS="." ; if ($1 >= 1 && $1 <= 127){printf $0"/8"} else if ($1 >= 128 && $1 <= 191){printf $0"/16"}else if ($1 >= 192 && $1 <= 223){printf $0"/24"} }'`gw $IPREMOTE >> /etc/ppp/routes2.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 >> /etc/ppp/routes2.log 2>&1;
                     fi;
                fi;
        done;
;;
41.*)
	echo $IPLOCAL >/etc/ppp/ipint.txt
;;
165.*)
	echo $IPLOCAL >/etc/ppp/ipint.txt
;;
esac
 
Last edited:
eremos, is that code in a file and you run that file everytime you run pon??
 
Ok thanx got it!!!

Now just to make sure it is routing trafic anybody know of a local site to check ip I use whatismyip.com to check international, not sure of local. (btw. it did show my international ip on whatismyip.com)

Thanx a million eremos! after tweaking and hacking and using your script it looks like it worked for me now just to make sure! :cool:
 
Ok thanx got it!!!

Now just to make sure it is routing trafic anybody know of a local site to check ip I use whatismyip.com to check international, not sure of local. (btw. it did show my international ip on whatismyip.com)

Thanx a million eremos! after tweaking and hacking and using your script it looks like it worked for me now just to make sure! :cool:

use iptraf to watch local connection and download something from a local site
 
Great idea didn't even think of that!!

Well it worked! Everything is setup and local is donwloading from local connection and international is well downloading from international connection!!

The advantage I have with using this setup, is that when I do decide to get a SAIX (WEB AFRICA) prepaid account to use for international all I have to do is edit my international connection, don't have to fiddle in the ip-up again, and same if I want to switch back to using IS for both accounts!
 
By the way, ASS_SAZiN`, would you be willing to post your whole script for anyone else who'd like to implement same? :)
 
Now we can start work on the South African ADSL multiple pppoe distro. ;)

You know that's really sad.
We have to start writing custom stuff just because of the bandwidth nonsense in this frigging country. :mad:
 
if i copy the code, remove spaces and tabs, hardcode the ips, take out the logging and paste it in terminal. It works! although to a certain extent, the -host for the ips with /32 gives some error (cant check now, at work)

I have the code in an executable script file called local in my /etc/ip-up.d/
directory. The advantage of that is that whatever scripts are in that folder, will be run everytime a ppp connection is made.

Could that be the problem?

I tried manually running the script file with no success.
 
By the way, ASS_SAZiN`, would you be willing to post your whole script for anyone else who'd like to implement same? :)

Yep will do writing every thing up and ironing out the script ( hard coded some stuff to point to my home dir etc.) Will post as soon as I get everything "nice" :)
 
Top
Sign up to the MyBroadband newsletter
X