Had an issue with setting up correct routing rule for VPN network through PPTP.
pppd didn't add corresponding rule automatically and I couldn't find
appropriate option to make it do so. So I tried adding something like the
following to the /etc/ppp/ip-up
script, which is invoked once network is
connected:
route add -net 10.2.0.0 netmask 255.255.0.0 dev ppp0
It didn't work. I thought maybe network is not available at the time the script is executed and tried:
shopt -u huponexit
( sleep 5 && route add -net 10.2.0.0 netmask 255.255.0.0 dev ppp0 ) &
Tests with simple scripts without root privileges indicated that the idea is
correct, but output of the route
command after connecting to the VPN still
didn't have the required item.
Looking on the Web trapped upon this hardly relevant post. It's not really related to the issue, but I noticed these two lines:
echo "/sbin/route add -net 172.16.2.0/24 gw 172.16.0.1" >> ip-up
echo "/sbin/route add -net 172.16.3.0/24 gw 172.16.0.1" >> ip-up
See something different comparing to commands in snippets above? It's
/sbin/route
, not just route
.
I always forget about not to rely on $PATH
environment variable in scripts
executed with superuser rights, hence the idea of this post is to remind just
that: prefer full paths in scripts executed with privileges of root user.