How to prevent the pppd to remove the default route

iproute2point-to-point-protocolpppoerouting

We use multiple providers, one of them to create connection uses pppoe through pppd daemon on ubuntu 14.04.

Early without multiple providers pppd manages default route by itself (creating it when connection is established and remove it when pppoe is down). But now I banned it with following options in peers/rt

nodefaultroute
noreplacedefaultroute

Because I need more complex ip rules for the running scheme with multiple providers.

I researched pppd scripts ip-up, ip-down, ip-up.d, ip-down.d but does not found removing default route.

So I assumed that it does it in their code.

I can add post-down directive in the provider configuration /etc/network/interfaces file as is:

ip route add default dev ppp60 table default

As a trick.

I planned to manage default route in separate init script.

Is there are a workaround for prevent pppd to manage (remove) a default route ?

UPDATE1:

I want to forbid pppd to remove default route default dev ppp60 scope link, when connections is reinitiating or go down.

I use interfaces(pppd is managed by ifup and ifdown commands) and standart debian/ubuntu network subsystem configuration tools, as is:

auto rt
iface rt inet ppp
provider rt
pre-up /sbin/ifconfig ethtop up
post-up until ip a | grep -q ppp60; do sleep 1 > /dev/null; done
post-up ip route add default via "$( ip -4 a show dev "ppp60" |   grep -E '\<peer\>' | sed -r 's/.*peer ([^ /]*).*/\1/' )" table isc-rt
post-up ip rule add pref 30001 fwmark "0x$( gethostip -x "$(ip -4 a show dev "ppp60" | grep -E '\<inet\>' | sed -r 's/.*inet ([^ /]*).*/\1/')" )" lookup isc-rt
post-up ip rule add pref 30002 from "$( ip -4 a show dev "ppp60" | grep -E '\<inet\>' | sed -r 's/.*inet ([^ /]*).*/\1/' )" lookup isc-rt
post-up ip rule add pref 30003 to "$( ip -4 a show dev "ppp60" | grep -E '\<peer\>' | sed -r 's/.*peer ([^ ]*).*/\1/'  )" lookup isc-rt
post-up /etc/init.d/fw restart
post-down ip route flush table isc-rt
post-down ip rule del pref 30001
post-down ip rule del pref 30002
post-down ip rule del pref 30003
post-down /etc/init.d/fw restart

That's my main routes:

root@gate:/etc/ppp# ip route list
default dev ppp60  scope link 
10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1 
10.8.0.0/24 via 192.168.128.13 dev br-eth0 
83.Y.Y.196 dev ppp60  proto kernel  scope link  src 93.Y.Y.67 
95.X.X.0/24 dev ethmiddle  proto kernel  scope link  src 95.X.X.40 
192.168.128.0/24 dev br-eth0  proto kernel  scope link  src 192.168.128.1 

Also I have tables for each provider with it's default gateway

That's my pppd options:

root@gate:/etc/ppp# awk '!/^ *#/ && NF' /etc/ppp/options 
asyncmap 0
noauth
crtscts
lock
hide-password
modem
lcp-echo-interval 30
lcp-echo-failure 4
noipx

That's my current provider peer config:

user "gsdf6sg84"
noipdefault
defaultroute
unit 60
hide-password
lcp-echo-interval 20
lcp-echo-failure 3
noauth
persist
mtu 1492
maxfail 0
plugin rp-pppoe.so ethtop
debug

Best Answer

The kernel (not pppd) automatically removes all related routes when corresponding interfaces are being removed.

Related Topic