Setup OpenVPN to PIA: verschil tussen versies

Uit Brakwiki
Ga naar: navigatie, zoeken
 
Regel 1: Regel 1:
  
 
sudo su -
 
sudo su -
 +
 
apt-get install openvpn unzip -y
 
apt-get install openvpn unzip -y
 
cd /etc/openvpn
 
cd /etc/openvpn
 +
 
wget https://www.privateinternetaccess.com/openvpn/openvpn.zip
 
wget https://www.privateinternetaccess.com/openvpn/openvpn.zip
 +
 
unzip openvpn.zip
 
unzip openvpn.zip
  
 
echo "p7873652" > /etc/openvpn/.secrets
 
echo "p7873652" > /etc/openvpn/.secrets
echo "q7W3cZ4JxH" >> /etc/openvpn/.secrets
+
 
 +
echo "password" >> /etc/openvpn/.secrets
 +
 
 
chmod 600 .secrets
 
chmod 600 .secrets
  
 
sed -i 's/auth-user-pass/auth-user-pass .secrets/g' *.ovpn
 
sed -i 's/auth-user-pass/auth-user-pass .secrets/g' *.ovpn
 +
 
rename "s/ovpn/conf/" *.ovpn
 
rename "s/ovpn/conf/" *.ovpn
  
Regel 16: Regel 22:
 
- remove comment (#) from line AUTOSTART=”all”
 
- remove comment (#) from line AUTOSTART=”all”
  
Test:
+
'''Test:'''
 +
 
 
systemctl start openvpn@Netherlands
 
systemctl start openvpn@Netherlands
 +
 
ip a
 
ip a
 +
 
- tun0 network should be visible
 
- tun0 network should be visible
 +
 
systemctl stop openvpn@Netherlands
 
systemctl stop openvpn@Netherlands
  
Regel 46: Regel 56:
 
Add line:
 
Add line:
  
* * * * * /usr/bin/chknet.sh >> /var/log/chknet.log 2>&1
+
<nowiki>*</nowiki> * * * * /usr/bin/chknet.sh >> /var/log/chknet.log 2>&1
  
  
Regel 58: Regel 68:
  
 
service openvpn start
 
service openvpn start
</pre>
 

Huidige versie van 27 jan 2019 om 03:13

sudo su -

apt-get install openvpn unzip -y cd /etc/openvpn

wget https://www.privateinternetaccess.com/openvpn/openvpn.zip

unzip openvpn.zip

echo "p7873652" > /etc/openvpn/.secrets

echo "password" >> /etc/openvpn/.secrets

chmod 600 .secrets

sed -i 's/auth-user-pass/auth-user-pass .secrets/g' *.ovpn

rename "s/ovpn/conf/" *.ovpn

nano /etc/default/openvpn - remove comment (#) from line AUTOSTART=”all”

Test:

systemctl start openvpn@Netherlands

ip a

- tun0 network should be visible

systemctl stop openvpn@Netherlands

systemctl enable openvpn@Netherlands

Auto restart on disconnect sudo su - nano /usr/bin/chknet.sh

#! /bin/bash
RESULT="$(ip a | grep -m 1 "tun0" | awk '{print $2}')"
DATE="$(date +%F_%T)"

if [ "$RESULT" == "tun0:" ] ; then
  echo "$DATE : tun0 still running"
else
 echo "$DATE : tun0 stopped, restarting...."
 systemctl start openvpn@Netherlands.service
fi

chmod +x chknet.sh

crontab -e

Add line:

* * * * * /usr/bin/chknet.sh >> /var/log/chknet.log 2>&1



Alternative:

  1. Start a connection to the PIA VPN with openvpn and the chosen config file with the following command (sudo openvpn "config-filename-goes-here.ovpn")

cp Netherlands.ovpn pia.ovpn

sed -i 's/#AUTOSTART="none"/AUTOSTART="pia"/g' openvpn

service openvpn start