OpenWrt Forum Archive

Topic: pptp / dhcp

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

my ISP uses dhcp to spread the network config,
and then uses pptp to get the real connection.

The pptp client is rewriting the default gw, which is correct. But the dhcp-client every several hours adds the old default gw. So then there are 2 default gateways, and my connection hangs.

Is there a simple method of telling the dhcp-client not to add the default gw on a "renew" ? I searched the system a bit, but i haven't found the point where the dhcp-client is started. If I am able to alter the execution it should be simple to write an dhcp-event script, which corrects the route.

Hi Squat,

Is there a simple method of telling the dhcp-client not to add the default gw on a "renew" ? I searched the system a bit, but i haven't found the point where the dhcp-client is started. If I am able to alter the execution it should be simple to write an dhcp-event script, which corrects the route.

Just take a look at /usr/share/udhcpc/default.script, might be what you're looking for.

--
Nico

Yes, this script (/usr/share/udhcpc/default.script) is the culprit in preventing pptp (and I would suspect any pppd based setup where the default route is replaced) from working 'out of the box'.  As it is currently, the script adds a default route when the dhcp lease is renewed, even if one already exists which is going through a different interface.  I have modified the script to deal with the problem, and believe it is ok.  Below is my patch.  Comments are welcome.  Specifically, is this modified script general enough that it won't cause problems with other setups, or is it only something which should be used in conjunction with pptp/pppd?

24,27c24,30
< 
<                         for i in $router ; do
<                                 route add default gw $i dev $interface
<                         done
---
>                         # only run the route add cmd if there is currently no other default route (i.e. via another interface)
>                         otherroute=`route|grep -v $interface|grep default`
>                         if [ -z "$otherroute" ] ; then
>                                 for i in $router ; do
>                                         route add default gw $i dev $interface
>                                 done
>                         fi

Good job edgimar, I had the same problem and your code solved it. Should be included in the next release imho.

Greetings
fuzzie

The discussion might have continued from here.