Bonjour à tous,
Merci Zobrak pour ce tuto qui complète bien celui de Kanka.ch. Cependant je n'y arrive pas. Je ne dois pas être très loin mais ça coince
Assez Nouveau sur Linux, je viens d'acquérir une rasp pi 2 sur laquelle j'ai installé openvpn et transmission et suivi la procédure indiquée.
J'ai un compte VPN sur Freedomip et un port ouvert udp tcp (30001)
J'ai transféré les ports 30001, 443 dans ma box numéricable (192.168.0.1) vers ma rasp en ip fixe 192.168.0.29.
Après un /etc/init.d/openvpn start et ifconfig, je n'ai pas de tun0 ( comme sbouby )
sur cat /var/log/syslog |grep openvpn, voici le message d'erreur :
raspberrypi ovpn-client[503]: WARNING: file '/etc/openvpn/freedomip/mdp/pass.txt' is group or others accessible
raspberrypi ovpn-client[503]: WARNING: file '/etc/openvpn/freedomip/ta.key' is group or others accessible
raspberrypi ovpn-client[503]: Control Channel Authentication: using '/etc/openvpn/freedomip/ta.key' as a OpenVPN static key file
raspberrypi ovpn-client[562]: /etc/openvpn/freedomip/scripts/up.sh tun0 1500 1560 10.8.1.154 10.8.1.153 init
raspberrypi systemd[1]: openvpn@client.service: main process exited, code=exited, status=1/FAILURE
raspberrypi systemd[1]: Unit openvpn@client.service entered failed state.
raspberrypi systemd[1]: Stopping system-openvpn.slice.
raspberrypi systemd[1]: Removed slice system-openvpn.slice
Voici mon "clientNL.conf":
client
# Ports availables: 443, 53, 8080, 1194, 110, 995
port 443
# Mode availables: TCP (default / safer) and UDP (faster)
proto tcp
dev tun
#Pas de modification depuis le serveur de la table de routage
route-nopull
remote nl.freedom-ip.com
resolv-retry infinite
ca /etc/openvpn/freedomip/ca.crt
tls-auth /etc/openvpn/freedomip/ta.key 1
auth-user-pass /etc/openvpn/freedomip/mdp/pass.txt
cipher AES-256-CBC
comp-lzo
verb 1
nobind
ns-cert-type server
script-security 2
up /etc/openvpn/up.sh
down /etc/openvpn/down.sh
;Maintien de la connexion: ping envoye toutes les 10s, restart si pas de reponses pendant 60s
keepalive 10 60
Mon fichier up.sh :
iptables -N SERVICES
#Obtenir l'adresse IP donnée par le VPN à tun0, à supposer que votre vpn crée une interface de ce nom.
NET_DEV="tun0"
NET_IP="$(command ifconfig "${NET_DEV}" \
| command grep 'inet ' \
| command sed -e 's/^.*inet [^:]*:\([^ ]*\) .*$/\1/')"
# Add a default route via <tun0> into the VPN routing table
ip route add default dev tun0 table VPN
# Pass traffic from lo:1 (192.168.10.1) to the VPN routing table, using policy routing ("ip rule" commands)
ip rule add from 192.168.10.1/32 table VPN
# Pass traffic from tun0 IP address to the VPN routing table
ip rule add from ${NET_IP}/32 table VPN
#On ajoute les règles iptables pour faire le NAT
# Source NAT and destination NAT rules
iptables -A PREROUTING -t nat -i tun0 -p tcp --dport 443 -j DNAT --to 192.168.10.1
iptables -A PREROUTING -t nat -i tun0 -p udp --dport 443 -j DNAT --to 192.168.10.1
iptables -A POSTROUTING -t nat -o tun0 -j MASQUERADE
# Allow session continuation traffic
iptables -A INPUT -i tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Allow Bittorrent traffic via tun0
iptables -A SERVICES -p tcp --dport 30001 -j ACCEPT # transmission random range
iptables -A SERVICES -p udp --dport 30001 -j ACCEPT # DHT
# Disallow BitTorrent traffic via eth0 - Just to be extra safe [img]/assets/images/smileys/wink.png[/img]
iptables -A FORWARD -s 192.168.10.1/32 -o eth0 -j DROP
#Démarrage de transmission
/etc/init.d/transmission-daemon restart
#Démarrage du script vérifiant que le VPN est toujours actif
killall checkVPN
/usr/bin/checkVPN &
Mon fichier down.sh :
NET_DEV="tun0"
NET_IP="$(command ifconfig "${NET_DEV}" \
| command grep 'inet ' \
| command sed -e 's/^.*inet [^:]*:\([^ ]*\) .*$/\1/')"
#On arrête le script qui va vérifier l'existence du tunnel VPN
killall checkVPN
#On arrête transmission
/etc/init.d/transmission-daemon stop
#On efface les regles iptables ajoutees
iptables -D FORWARD -s 192.168.10.1/32 -o eth0 -j DROP
iptables -D SERVICES -p udp --dport 30001 -j ACCEPT # DHT
iptables -D SERVICES -p tcp --dport 30001 -j ACCEPT # rTorrent random range
iptables -D INPUT -i tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -D POSTROUTING -t nat -o tun0 -j MASQUERADE
iptables -D PREROUTING -t nat -i tun0 -p udp --dport 443 -j DNAT --to 192.168.10.1
iptables -D PREROUTING -t nat -i tun0 -p tcp --dport 443 -j DNAT --to 192.168.10.1
Remove rule for the secondary loopback IP address (192.168.0.1)
ip rule del from 192.168.10.1/32 table VPN
Remove rule for tun0 IP address
ip rule del from ${NET_IP}/32 table VPN
Remove the default route via tun0 from the IPRED routing table
ip route del default dev tun0 table VPN
Interface :
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto lo:1
iface lo:1 inet static
address 192.168.10.1
netmask 255.255.255.255
les lignes importantes de transmission settings.json
"bind-address-ipv4": "192.168.10.1",
"bind-address-ipv6": "fe80::",
"blocklist-enabled": false,
"download-dir": "/media/disque1/Data",
"incomplete-dir": "/media/disque1/Temp",
"incomplete-dir-enabled": true,
"peer-port": 30001,
"peer-port-random-high": 30001,
"peer-port-random-low": 30001,
"peer-port-random-on-start": false,
"port-forwarding-enabled": false,
"rpc-bind-address": "0.0.0.0",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "moi", (pour les essais)
"rpc-whitelist": "127.0.0.1",
"rpc-whitelist-enabled": false,
mon fichier interfaces :
Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto lo:1
iface lo:1 inet static
address 192.168.10.1
netmask 255.255.255.255
mon rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 VPN
mon checkVPN :
while [ 1 > 0 ]; do
sleep 300
T=`ping -I 192.168.10.1 -c 1 [url=http://www.google.com]www.google.com[/url] |grep "packets transmitted"`
if [[ ${T:23:1} != "1" ]]
then
/etc/init.d/openvpn restart
fi
done
si cette discussion est toujours suivie, est-ce qu'une âme charitable pourrait m'aider et m'indiquer où se trouve mon (mes) erreurs ?
Merci d'avance
PS : au passage, comment faites-vous pour que votre code soit sur fond noir ?