Configuration de mon VPN

Quelqu’un pourrait-il m’aider à configurer mon VPN avec network-manager?

Je suis actuellement sous openvpn.se, et je dispose des éléments suivants:
un username, un password, et un unique certificat.

Je me connecte bien en ligne de commande, mais je voudrais maintenant me connecter grâce au network-manager (pour bénéficier notamment du VPNautoconnect).

Dans ma config. de network manager, que dois-je choisir comme type d’authentification?
certificates (TLS) ou Password ou Password with certificates (TLS) ou Static Key?

J’ai tenté Password seul, en renseignant mon login/password et certificat. Mais dans gateWay, que dois-je mettre? L’IP de mon routeur? (je passe par un routeur qui fait office de dhcp).

J’ai cherché de la doc un peu partout mais pas grand chose autour de network-manager.

Merci.

Voici les traces de mon syslog lors de la tentative de cnx:

Feb 3 22:07:20 toto NetworkManager[2048]: Starting VPN service ‘org.freedesktop.NetworkManager.openvpn’…
Feb 3 22:07:20 toto NetworkManager[2048]: VPN service ‘org.freedesktop.NetworkManager.openvpn’ started (org.freedesktop.Netw$
Feb 3 22:07:20 toto NetworkManager[2048]: VPN service ‘org.freedesktop.NetworkManager.openvpn’ appeared, activating connecti$
Feb 3 22:07:20 toto NetworkManager[2048]: VPN plugin state changed: 1
Feb 3 22:07:20 toto vpnautoconnect[2133]: insert connection VPN connection 1 in hash
Feb 3 22:07:20 toto vpnautoconnect[2133]: VPN connection 1 in authentification…
Feb 3 22:07:20 toto vpnautoconnect[2133]: VPN connection 1 is being established
Feb 3 22:07:20 toto NetworkManager[2048]: VPN plugin state changed: 3
Feb 3 22:07:20 toto NetworkManager[2048]: VPN connection ‘VPN connection 1’ (Connect) reply received.
Feb 3 22:07:20 toto vpnautoconnect[2133]: VPN connection 1 is getting an IP address
Feb 3 22:07:20 toto nm-openvpn[30153]: OpenVPN 2.1.3 x86_64-pc-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [MH] [PF_INET6] [eurephia] b$
Feb 3 22:07:20 toto nm-openvpn[30153]: WARNING: No server certificate verification method has been enabled. See openvpn.net$
Feb 3 22:07:20 toto nm-openvpn[30153]: NOTE: the current --script-security setting may allow this configuration to call user-define$
Feb 3 22:07:20 toto nm-openvpn[30153]: UDPv4 link local: [undef]
Feb 3 22:07:20 toto nm-openvpn[30153]: UDPv4 link remote: [AF_INET]192.168.123.1:1194
Feb 3 22:07:20 toto nm-openvpn[30153]: read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
Feb 3 22:07:22 toto nm-openvpn[30153]: read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
Feb 3 22:07:27 toto nm-openvpn[30153]: read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
Feb 3 22:07:35 toto nm-openvpn[30153]: read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
Feb 3 22:07:51 toto nm-openvpn[30153]: read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
Feb 3 22:08:00 toto NetworkManager[2048]: VPN connection ‘VPN connection 1’ (IP Config Get) timeout exceeded.
Feb 3 22:08:00 toto nm-openvpn[30153]: SIGTERM[hard,] received, process exiting
Feb 3 22:08:00 toto NetworkManager[2048]: (wlan0): writing resolv.conf to /sbin/resolvconf
Feb 3 22:08:00 toto vpnautoconnect[2133]: VPN connection 1 connection failed

Voici mon openvpn.conf (fourni par le provider):

float
client
dev tap
proto udp
nobind
; Cert
ca /etc/openvpn/keys/ca.crt
ns-cert-type server
cipher BF-CBC #Blowfish
;Vpn server
remote-random
remote melissa.vpntunnel.se 1194
remote melissa.vpntunnel.se 10010
remote melissa.vpntunnel.se 10020
;Auth
#auth-user-pass #passwd
auth-user-pass auth.conf
persist-key
persist-tun
; Logging
comp-lzo
verb 1

Bon il y a du nouveau, en cochant “use a TAP device” dans la configuration avancée du VPN, j’arrive maintenant à me connecter au VPN, sauf que je ne ping plus. Le VPN autoconnect tente de multiples reconnexions:

Syslog:

Feb 3 22:42:13 toto avahi-daemon[1910]: Leaving mDNS multicast group on interface tap0.IPv4 with address 178.73.211.66. Feb 3 22:42:13 toto avahi-daemon[1910]: Interface tap0.IPv4 no longer relevant for mDNS. Feb 3 22:42:13 toto avahi-daemon[1910]: Joining mDNS multicast group on interface tap0.IPv4 with address 178.73.211.66. Feb 3 22:42:13 toto nm-openvpn[6023]: /usr/lib/NetworkManager/nm-openvpn-service-openvpn-helper tap0 1500 1573 178.73.211.66 255.25$ Feb 3 22:42:13 toto avahi-daemon[1910]: New relevant interface tap0.IPv4 for mDNS. Feb 3 22:42:13 toto avahi-daemon[1910]: Registering new address record for 178.73.211.66 on tap0.IPv4. Feb 3 22:42:13 toto NetworkManager[2048]: <info> VPN connection 'VPN connection 1' (IP Config Get) reply received. Feb 3 22:42:13 toto NetworkManager[2048]: <info> VPN Gateway: 178.73.212.235 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Internal Gateway: 178.73.211.1 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Tunnel Device: tap0 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Internal IP4 Address: 178.73.211.66 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Internal IP4 Prefix: 24 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Internal IP4 Point-to-Point Address: 0.0.0.0 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Maximum Segment Size (MSS): 0 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Internal IP4 DNS: 80.67.0.2 Feb 3 22:42:13 toto NetworkManager[2048]: <info> Internal IP4 DNS: 91.213.246.2 Feb 3 22:42:13 toto NetworkManager[2048]: <info> DNS Domain: '(none)' Feb 3 22:42:13 toto nm-openvpn[6023]: Initialization Sequence Completed Feb 3 22:42:14 toto NetworkManager[2048]: <info> (tap0): writing resolv.conf to /sbin/resolvconf Feb 3 22:42:14 toto avahi-daemon[1910]: Joining mDNS multicast group on interface tap0.IPv6 with address fe80::34d5:39ff:fe6d:37e4. Feb 3 22:42:14 toto avahi-daemon[1910]: New relevant interface tap0.IPv6 for mDNS. Feb 3 22:42:14 toto avahi-daemon[1910]: Registering new address record for fe80::34d5:39ff:fe6d:37e4 on tap0.*. Feb 3 22:42:16 toto NetworkManager[2048]: <info> VPN connection 'VPN connection 1' (IP Config Get) complete. Feb 3 22:42:16 toto NetworkManager[2048]: <info> (tap0): writing resolv.conf to /sbin/resolvconf Feb 3 22:42:16 toto vpnautoconnect[2133]: VPN connection 1 is active Feb 3 22:42:16 toto NetworkManager[2048]: <info> Policy set 'VPN connection 1' (tap0) as default for IPv4 routing and DNS. Feb 3 22:42:16 toto NetworkManager[2048]: <info> VPN plugin state changed: 4 Feb 3 22:42:16 toto vpnautoconnect[2133]: insert connection VPN connection 1 in hash Feb 3 22:42:16 toto vpnautoconnect[2133]: Connection VPN connection 1 activated Feb 3 22:42:17 toto dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 9

up :blush:

Tu n’as pas essayé sans le network-manager??
Sinon que te donnes un ifconfig et un route -n une fois le VPN lancé?

[quote=“fran.b”]Tu n’as pas essayé sans le network-manager??
Sinon que te donnes un ifconfig et un route -n une fois le VPN lancé?[/quote]

Oui sans le network-manager ca fonctionne très bien.

ifconfig:

[code]eth0 Link encap:Ethernet HWaddr 00:26:9e:42:b3:af
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:28

eth0:avahi Link encap:Ethernet HWaddr 00:26:9e:42:b3:af
inet addr:169.254.9.96 Bcast:169.254.255.255 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:28

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:13276 errors:0 dropped:0 overruns:0 frame:0
TX packets:13276 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:797905 (779.2 KiB) TX bytes:797905 (779.2 KiB)

tap0 Link encap:Ethernet HWaddr ce:02:61:a4:d0:bb
inet addr:178.73.211.20 Bcast:178.73.211.255 Mask:255.255.255.0
inet6 addr: fe80::cc02:61ff:fea4:d0bb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2921089 errors:0 dropped:0 overruns:0 frame:0
TX packets:62865 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:196630006 (187.5 MiB) TX bytes:10398126 (9.9 MiB)

wlan0 Link encap:Ethernet HWaddr 0c:ee:e6:85:f1:b6
inet addr:192.168.123.2 Bcast:192.168.123.255 Mask:255.255.255.0
inet6 addr: fe80::eee:e6ff:fe85:f1b6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2946574 errors:0 dropped:0 overruns:0 frame:0
TX packets:81098 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:420594783 (401.1 MiB) TX bytes:18076987 (17.2 MiB)[/code]

route -n

Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 178.73.212.235 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.48.4 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.40.254 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 127.0.0.1 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 178.73.211.0 0.0.0.0 255.255.255.0 U 0 0 0 tap0 192.168.123.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlan0 0.0.0.0 178.73.211.1 128.0.0.0 UG 0 0 0 tap0 128.0.0.0 178.73.211.1 128.0.0.0 UG 0 0 0 tap0 0.0.0.0 192.168.123.1 0.0.0.0 UG 0 0 0 wlan0 0.0.0.0 0.0.0.0 0.0.0.0 U 1002 0 0 eth0

Tu as deux passerelles: 192.168.123.1 et 178.73.211.1, une route vers 127.0.0.1 via la passerelle 192.168.123.1 qui est aberrante, une route vers 178.73.212.235 qui doit être ton serveur VPN qui semble être normale. À moins que tu n’utilises plusieurs tables de routages (je serais sur des oeufs dans ce cas) ta table me parait plus que curieuse. Que donne

ip route list

pour confirmer. En tout cas, ça ne m’étonnes pas que ça coince.

178.73.212.234 via 192.168.123.1 dev wlan0 212.27.48.4 via 192.168.123.1 dev wlan0 212.27.40.254 via 192.168.123.1 dev wlan0 127.0.0.1 via 192.168.123.1 dev wlan0 188.126.70.0/24 dev tap0 proto kernel scope link src 188.126.70.229 192.168.123.0/24 dev wlan0 proto kernel scope link src 192.168.123.2 metric 2 169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.9.96 169.254.0.0/16 dev wlan0 scope link metric 1000 0.0.0.0/1 via 188.126.70.1 dev tap0 128.0.0.0/1 via 188.126.70.1 dev tap0 default via 192.168.123.1 dev wlan0 proto static default dev eth0 scope link metric 1002

Comment faire sauter cette passerelle 127.0.0.1 dans ce cas?

Il y a un léger mieux après suppression de la route en 127.0.0.1
Le VPN de network-manager se connecte, mais je ne navigue pas.

Il y a un principe que je ne comprends pas:
dans mes services (init.d), j’ai un openvpn.

Faut-il que ce service soit démarré en parallèle de network-manager?

Ou puis-je arrêter en principe ce service (ou daemon?) et network-manager s’occupe de tout?

Car si je laisse démarrer openvpn seul, tout fonctionne (un tap0 monte). Si le vpn de network-manager démarre derrière (un tap1 apparaît en plus), et une fois sur deux je perds la navigation, mais network manager m’indique que le vpn est bien connecté.

Regarde le contenu de /etc/default/openvpn.

Pour ta table,

178.73.212.235 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.48.4 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.40.254 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 127.0.0.1 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 178.73.211.0 0.0.0.0 255.255.255.0 U 0 0 0 tap0 192.168.123.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlan0 0.0.0.0 178.73.211.1 128.0.0.0 UG 0 0 0 tap0 128.0.0.0 178.73.211.1 128.0.0.0 UG 0 0 0 tap0 0.0.0.0 192.168.123.1 0.0.0.0 UG 0 0 0 wlan0 0.0.0.0 0.0.0.0 0.0.0.0 U 1002 0 0 eth0

Fais

route del -host 127.0.0.1 gw 192.168.123.1 route del default gw 192.168.123.1 Ça devrait aller mieux. Mais ta table est vraiment curieuse. Je ne connais pas network manager, je n’utilise pas ce truc.

Merci Fran:

[code]route del default gw 192.168.123.1
SIOCDELRT: No such process

/home/corax# route del -host 127.0.0.1 gw 192.168.123.1
ok[/code]

Actuellement, avec ma connexion fonctionnant (soit openvpn + network-manager):
route -n

178.73.212.236 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 178.73.212.236 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.48.4 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.40.254 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 192.168.123.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0 178.73.204.0 0.0.0.0 255.255.255.0 U 0 0 0 tap0 178.73.204.0 0.0.0.0 255.255.255.0 U 0 0 0 tap1 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlan0 0.0.0.0 178.73.204.1 128.0.0.0 UG 0 0 0 tap0 128.0.0.0 178.73.204.1 128.0.0.0 UG 0 0 0 tap0 0.0.0.0 178.73.204.1 0.0.0.0 UG 0 0 0 tap1 0.0.0.0 0.0.0.0 0.0.0.0 U 1002 0 0 eth0

ip route list:

178.73.212.236 via 192.168.123.1 dev wlan0 proto static 178.73.212.236 via 192.168.123.1 dev wlan0 212.27.48.4 via 192.168.123.1 dev wlan0 212.27.40.254 via 192.168.123.1 dev wlan0 192.168.123.0/24 dev wlan0 proto kernel scope link src 192.168.123.2 metric 2 178.73.204.0/24 dev tap0 proto kernel scope link src 178.73.204.241 178.73.204.0/24 dev tap1 proto kernel scope link src 178.73.204.25 169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.9.96 169.254.0.0/16 dev wlan0 scope link metric 1000 0.0.0.0/1 via 178.73.204.1 dev tap0 128.0.0.0/1 via 178.73.204.1 dev tap0 default via 178.73.204.1 dev tap1 proto static default dev eth0 scope link metric 1002

Et si je coupe openvpn (service openvpn stop) puis que je connecte le vpn uniquement via network-manager, il apparaît bien comme connecté (visuellement), je ne navigue plus, et:

route -n

178.73.212.236 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.48.4 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 178.73.212.226 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 212.27.40.254 192.168.123.1 255.255.255.255 UGH 0 0 0 wlan0 178.73.206.0 0.0.0.0 255.255.255.0 U 0 0 0 tap0 192.168.123.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlan0 0.0.0.0 178.73.206.1 0.0.0.0 UG 0 0 0 tap0 0.0.0.0 0.0.0.0 0.0.0.0 U 1002 0 0 eth0

ip route list:

178.73.212.236 via 192.168.123.1 dev wlan0 212.27.48.4 via 192.168.123.1 dev wlan0 212.27.40.254 via 192.168.123.1 dev wlan0 192.168.123.0/24 dev wlan0 proto kernel scope link src 192.168.123.2 metric 2 169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.9.96 169.254.0.0/16 dev wlan0 scope link metric 1000 default via 192.168.123.1 dev wlan0 proto static default dev eth0 scope link metric 1002

Dans le premier cas tu as 2 VPN lancés en parallèle c’est ça qui met la pagaille mais coup de chance, la passerelle est la même (178.73.204.1) Dans le deuxième cas, tu es sur 178.73.206.1, je pense que ce stade c’est la pagaille et que le réseau ne fonctionne plus.

Merci mais comment puis-je faire dans ce cas?

Car à aucun moment je n’indique dans mon network-manager une ip liée au VPN.

Par contre j’indique bien un alias de mémoire.

Finalement j’ai trouvé: coup de bol:

Il fallait juste cocher LZO data compression.

Merci à tous pour votre aide.

Je vais en parallèle faire le ménage dans ma table de routage.