IOFlood VPN Ubuntu 20.04, 22.04 & Debian 9 Server Auto Connect/ReConnect Setup
In order to connect to IOFloods VPN from Ubuntu 20.04, 22.04 or Debian 9 server or similar linux systems, you will need to do the following as root or sudo user.
Key *:
USERNAME: Use the Username assigned to your VPN Access
PASSWORD: Use the Password assigned to your VPN Access
*** Note ***
If a new server gets added to your account, you must restart the VPN to pickup the new route to the new IPMI IP address before you can connect to it.
1. Install required packages
apt install pptp-linux network-manager-pptp -y
2. Create credential file for VPN Access *
echo "USERNAME PPTP PASSWORD 107.167.83.4" >> /etc/ppp/chap-secrets
3. Setup VPN Route config
cat > /etc/ppp/ip-up.d/route-traffic <<EOF
#!/bin/bash
NET1="10.10.0.0/16"
IFACE="ppp0"
route add -net \${NET1} dev \${IFACE}
EOF
4. Make VPN Route config executable
chmod +x /etc/ppp/ip-up.d/route-traffic
5. Create VPN PPP connection config *
cat > /etc/ppp/peers/ioflood <<EOF
pty "pptp 107.167.83.4 --nolaunchpppd"
name USERNAME
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam ioflood
EOF
6. Allow PPTP through firewall UFW or IPTABLES
UFW:
ufw allow 1723
ufw disable
ufw enable
IPTABLES:
iptables -A INPUT -i pptp -j ACCEPT
iptables -A OUTPUT -o pptp -j ACCEPT
iptables-save > /etc/iptables/rules.v4
Once completed you should be able to start and connect to the VPN by running the first command below.
Starting VPN:
pon ioflood
Stopping VPN:
poff ioflood
**** Optional Auto ReConnect cron script ****
This script will ping one of your IPMIs and if no response restart the VPN connection.
Key *:
IPMIip: Use IP address of IPMI you want to monitor for valid connection EX: 10.10.70.11
1. Make Directory to store script
mkdir /opt/ioflood
2. Create script (Change IPMIip to an IPMI IP you want to monitor) *
cat > /opt/ioflood/iofloodvpnchk.sh <<'EOF'
#!/bin/bash
HOST=IPMIip
DATE=`date`
PINGRES=`ping -c 2 $HOST`
PLOSS=`echo $PINGRES : | grep -oP '\d+(?=% packet loss)'`
echo "$DATE : Loss Result : $PLOSS"
if [ "100" -eq "$PLOSS" ];
then
echo "$DATE : Starting : IOFlood VPN"
pon ioflood
echo "$DATE : Now running : IOFlood VPN"
else
echo "$DATE : Already running : IOFlood VPN"
fi
EOF
3. Make script executable
chmod +x /opt/ioflood/iofloodvpnchk.sh
4. Add the cron to run the script
crontab -e
Now add this to the cron and save
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/1 * * * * /opt/ioflood/iofloodvpnchk.sh >> /tmp/iofloodvpn.log 2>&1
Once you have setup the cron you can test it by stopping the VPN waiting 1 minute and checking if the connection was restored.
Stopping VPN
poff ioflood
Checking for VPN connection, Look for ppp0 section
ip a
Response to look for
4: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1396 qdisc pfifo_fast state UNKNOWN group default qlen 3
link/ppp
inet 10.111.5.100 peer 10.167.4.1/32 scope global ppp0
valid_lft forever preferred_lft forever