Afficher/cacher Sommaire
Debian OpenVPN (Connexion Auto Private Internet Access)
Installer les applications
sudo apt install network-manager-openvpn # qui va installer openvpn
Téléchargement des fichiers de configuration OpenVPN (extension .ovpn) Private Internet Access
sudo -s
cd /etc/openvpn/client
wget --no-check-certificate https://www.privateinternetaccess.com/openvpn/openvpn.zip
Créer un fichier de login
nano /etc/openvpn/login.conf
Le fichier contient 2 lignes , login sur ligne 1 et mot de passe sur ligne 2
create: 2017-05-29 modifier les droits
chmod 0600 /etc/openvpn/login.conf
chown root:root /etc/openvpn/login.conf
Tester une configuration openVPN
cd /etc/openvpn/client
openvpn --config '/etc/openvpn/client/US New York City.ovpn' --auth-user-pass /etc/openvpn/login.conf
[...]
Mon May 29 17:36:42 2017 TUN/TAP device tun0 opened
Mon May 29 17:36:42 2017 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Mon May 29 17:36:42 2017 /sbin/ip link set dev tun0 up mtu 1500
Mon May 29 17:36:42 2017 /sbin/ip addr add dev tun0 local 10.7.10.10 peer 10.7.10.9
Mon May 29 17:36:42 2017 Initialization Sequence Completed
Ctrl C pour l’arrêt
Dans une autre fenêtre de terminal , vérifier l’adresse ip de notre connexion vpn qui doit être différente de votre adresse publique
wget http://ipinfo.io/ip -qO -
196.52.2.38
Autoconnect PIA VPN sur Boot
Créez le fichier de script de démarrage init.d de OpenVPN
sudo nano /etc/init.d/openvpnauto
#!/bin/sh
### BEGIN INIT INFO
# Provides: OpenVPN Autoconnect
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenVPN Autoconnect
# Description: OpenVPN Autoconnect
### END INIT INFO
# Documentation available at
# http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
# Debian provides some extra functions though. /lib/lsb/init-functions
DAEMON_NAME="openvpnauto"
DAEMON_USER=root
DAEMON_PATH="/usr/sbin/openvpn"
DAEMON_OPTS="--config /etc/openvpn/client/Sweden.ovpn --auth-user-pass /etc/openvpn/login.conf"
DAEMON_PWD="/etc/openvpn/client"
DAEMON_DESC=$(get_lsb_header_val $0 "Short-Description")
DAEMON_PID="/var/run/${DAEMON_NAME}.pid"
DAEMON_NICE=0
DAEMON_LOG='/var/log/openvpnauto.log'
[ -r "/etc/default/${DAEMON_NAME}" ] && . "/etc/default/${DAEMON_NAME}"
do_start() {
local result
pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
if [ $? -eq 0 ]; then
log_warning_msg "${DAEMON_NAME} is already started"
result=0
else
log_daemon_msg "Starting ${DAEMON_DESC}" "${DAEMON_NAME}"
touch "${DAEMON_LOG}"
chown $DAEMON_USER "${DAEMON_LOG}"
chmod u+rw "${DAEMON_LOG}"
if [ -z "${DAEMON_USER}" ]; then
start-stop-daemon --start --quiet --oknodo --background \
--nicelevel $DAEMON_NICE \
--chdir "${DAEMON_PWD}" \
--pidfile "${DAEMON_PID}" --make-pidfile \
--exec "${DAEMON_PATH}" -- $DAEMON_OPTS
result=$?
else
start-stop-daemon --start --quiet --oknodo --background \
--nicelevel $DAEMON_NICE \
--chdir "${DAEMON_PWD}" \
--pidfile "${DAEMON_PID}" --make-pidfile \
--chuid "${DAEMON_USER}" \
--exec "${DAEMON_PATH}" -- $DAEMON_OPTS
result=$?
fi
log_end_msg $result
fi
return $result
}
do_stop() {
local result
pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
if [ $? -ne 0 ]; then
log_warning_msg "${DAEMON_NAME} is not started"
result=0
else
log_daemon_msg "Stopping ${DAEMON_DESC}" "${DAEMON_NAME}"
killproc -p "${DAEMON_PID}" "${DAEMON_PATH}"
result=$?
log_end_msg $result
rm "${DAEMON_PID}"
fi
return $result
}
do_restart() {
local result
do_stop
result=$?
if [ $result = 0 ]; then
do_start
result=$?
fi
return $result
}
do_status() {
local result
status_of_proc -p "${DAEMON_PID}" "${DAEMON_PATH}" "${DAEMON_NAME}"
result=$?
return $result
}
do_usage() {
echo $"Usage: $0 {start | stop | restart | status}"
exit 1
}
case "$1" in
start) do_start; exit $? ;;
stop) do_stop; exit $? ;;
restart) do_restart; exit $? ;;
status) do_status; exit $? ;;
*) do_usage; exit 1 ;;
esac
Ctrl+X, Y et Entrée pour Sauver
Enable the OpenVPN PIA Autoconnect script
sudo chmod +x /etc/init.d/openvpnauto
sudo update-rc.d openvpnauto defaults 98
Now you can connect to PIA’s VPN automatically by running
sudo service openvpnauto start
Vérification
wget http://ipinfo.io/ip -qO -
Effectuer la même opération après reboot