dhcpcd-discuss

Re: preserving l2tp

Roy Marples

Wed Dec 29 13:31:45 2010

Hi

On Wed, 2010-12-29 at 14:13 +0200, Niv wrote:
> hi, 
> I want dhcpcd to query my isp for the default gate way, WAN_GW, 
> but rather then use it I want to use it this way: 
> ip ro add $L2TP_SERVER_IP via $WAN_GW 
> 
> now I can use the l2tp server as the defualt route.

Because dhcpcd handles routing internally as opposed to hooks this is
tricky, but not impossible.

Basically add the nogateway option to dhcpcd.conf and use something like
this in a hook script:

if [ -n "$new_classless_static_routes" ]; then
   set -- $new_classless_static_routes
   while [ -n "$1" ]; do
      if [ "$1" = "0.0.0.0/0" ]; then
        ip ro add "$L2TP_SERVER_IP" via "$2"
      fi
      shift; shift;
   done
elif [ -n "$new_routers" ]; then
   set -- $new_routers
   ip ro add "$L2TP_SERVER_IP" via "$1"
fi

You would need to handle removal of the route as well. You can use $ifup
and $ifdown as tests to see if we're taking the interface up or down as
a result of running the hook. I've just typed the above directly into
the email so to may or may not work :)

Thanks

Roy


Follow-Ups:
Re: preserving l2tpNiv
References:
preserving l2tpNiv
Archive administrator: postmaster@marples.name