I have a linux web server and I need to create an on-demand l2tp ipsec VPN connection with a network route. The VPN connection works and the route is automatically created via a script in /etc/ppp/ip-up.d that expects device ppp0. Everything works fine when I run the following on the command line:
echo "c myvpn" > /var/run/xl2tpd/l2tp-control
As expected, the vpn connects via ppp0 and my route is created. However, when I run this exact same command from a script, sometimes the VPN connects using ppp1 which causes the route creation to fail.
Why is this happening? There is no other network activity going on. Is there a way to specify which network interface gets used?