Subject: Problems with pppd and route
To: None <tech-net@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-net
Date: 05/27/2004 03:11:27
In short: can i change routing tables inside ip-up/ip-down pppd scripts or 
not ?

In details, the scheme looks like this:

ppp -> GPRS -> Internet -> server

I.e. i connect with PPP/GPRS to the ISP and want to access some server inside 
Internet. I know server's IP address and it's supposed to be fixed and 
unchanged.

When i connect to the ISP with PPP/GPRS all works really fine and finally i 
got two addresses for ppp0 interface: local and remote. Usually local address 
is like 10.0.a.b and remote is almost always 10.0.0.1 and i use it as a 
gateway to access Inet through PPP.

When i use "defaultroute" option with pppd or when after connection is 
established i manually add an entry in the routing table like "route add 
<server> 10.0.0.1" i can ping the server and so on.

Ok, but looks like i can add this entry into routing table only when ppp0 
interface is configured and there is known route for 10.0.0.1 itself. The 
same i don't need this entry in the table when i disconnect from ISP and ppp0 
goes down.

So i decided to add and remove this fixed routing entry from /etc/ppp/ip-up 
and ip-down scripts. Like below:

---ip up---
#!/bin/sh
remote=$5
route add server $remote
---ip up---

---ip down---
#!/bin/sh
route delete server
---ip down---

Both scripts are called fine by pppd and i can see that pppd passes correct 
remote host IP address. Same as i'm sure that route is called too. Scripts 
are running as root, as expected.

The problem is that ip-up script doesn't actually change the routing table. It 
stays unchanged regardless to "route add" request ! Only when ip-up script 
terminates and pppd goes online i can execute the same "route add" command 
with success. But this isn't what i want to do :(

My question is - how to automatically fix routing tables after pppd daemon 
enters/leaves online state ?

Any ideas and what I'm doing wrong ?

// wbr