Open dmp1ce opened 5 years ago
Hi,
I would propose a slight amendment to startup.sh.
#!/bin/bash
sed -i 's/right=.*/right='$VPN_SERVER_IPV4'/' /etc/ipsec.conf
echo ': PSK "'$VPN_PSK'"' > /etc/ipsec.secrets
sed -i 's/lns = .*/lns = '$VPN_SERVER_IPV4'/' /etc/xl2tpd/xl2tpd.conf
sed -i 's/name .*/name '$VPN_USERNAME'/' /etc/ppp/options.l2tpd.client
sed -i 's/password .*/password '$VPN_PASSWORD'/' /etc/ppp/options.l2tpd.client
# startup ipsec tunnel
PIDFILE=/var/run/charon.pid
/usr/sbin/ipsec start
sleep 2
ipsec up L2TP-PSK
sleep 2
ipsec statusall
/usr/sbin/xl2tpd
sleep 2
xl2tpd-control connect-lac LAC
sleep 10
/sbin/ip route add $VPN_CHECK_IP dev ppp0
# check if IP is reachable:
for (( ; ; ))
do
sleep 60s
/bin/ping -c 3 $VPN_CHECK_IP > /dev/null
if [[ $? != 0 ]]; then
echo Can\'t reach remote host, exiting...
break;
fi
done
The container will exit if it can't reach a host in VPN. Then it will restart if started with
restart: unless-stopped
After I turn off the VPN with
docker-compose stop
I cannot connect again with adocker-compose up -d
. I get the following output unless I remove the volume withdocker-compose rm -v
.Here is my
docker-compose.yml
: