Projet

Général

Profil

Id2ndR » Historique » Version 4

« Précédent - Version 4/13 (diff) - Suivant » - Version actuelle
Fabien ADAM, 07/12/2014 10:24


Mes travaux perso relatifs à Tetaneutral

Auteur : Id2ndR

Virtualisation

Au dessus, de libvirt, je fais tourner quelques VM sur ma machine Zbox ID18 http://www.ldlc.com/fiche/PB00158714.html : Celeron double cœurs supportant le VT, avec 8Go de RAM

OpenWRT

Je possède un TP-Link WDR3600 gigabit et double bande N. Il tourne sous Barrier Breaker 14.04.

Objectifs :
- connecter le routeur à Internet via une connexion 4G
- sortir sur une VM tournant sur ma machine à Tetaneutral, pour avoir un accès réseau complet (IP fixe, IPv6, téléphonie SIP, pas de bridage ni de modification du flux via les proxys transparents)
- brancher un téléphone IP ethernet (offre Plug&Phone d'OVH) qui passe dans le VPN, et qui fonctionne normalement sans aucune configuration

4G

Inspiré de http://wiki.openwrt.org/doc/howto/usb.tethering

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-usb-net-rndis
root@OpenWrt:~# insmod usbnet
root@OpenWrt:~# insmod cdc_ether
root@OpenWrt:~# insmod rndis_host
root@OpenWrt:~# ifconfig usb0
usb0      Link encap:Ethernet  HWaddr 02:34:68:55:02:03  
          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)

Dans Luci, Network > Interfaces : créer une interface nommée 4G exploitant l'interface usb0, en client dhcp

Pinguer depuis le routeur.

OpenVPN

Mise en place :
  • Certificat SSL du serveur (VM) : généré par CA-Cert (je n'ai jamais pu faire marcher le VPN sur OpenWRT avec un certificat auto-signé)
  • Certificat d'un certificat client : généré avec easy-rsa (build-ca, build-key-server, build-key). Remarque : il n'est pas nécessaire que ces certificats soient issues du certificat du serveur vérifié à la connexion, car le serveur connaît son référentiel de clef, indépendament du certificat serveur présenté sur le port d'écoute.
  • Configuration du serveur :
    id2ndr@id2ndr-vm: ~$ cat /etc/openvpn/id2ndr.conf 
    ##################################
    dev tun
    proto udp
    port 1194
    
    ca /etc/openvpn/easy-rsa/keys/class3.crt
    cert /etc/openvpn/easy-rsa/keys/id2ndr.toulan.fr.crt
    key /etc/openvpn/easy-rsa/keys/id2ndr.toulan.fr.key
    dh /etc/openvpn/easy-rsa/keys/dh1024.pem
    
    user nobody
    group nogroup
    server 10.9.0.0 255.255.255.0
    
    persist-key
    #persist-tun
    
    keepalive 10 100
    
    status /var/log/openvpn-status.log
    verb 3
    client-to-client
    
    #push "redirect-gateway def1" 
    #set the dns servers
    #push "dhcp-option DNS 8.8.8.8" 
    #push "dhcp-option DNS 8.8.4.4" 
    push "redirect-gateway def1" 
    push dhcp-option DNS 91.224.149.254
    
    log-append /var/log/openvpn
    comp-lzo adaptive
    
  • Installation du client :
    root@OpenWrt:~# opkg update; opkg install openvpn-openssl
    root@OpenWrt:~# uci set openvpn.custom_config.enabled=1
    root@OpenWrt:~# uci commit
    root@OpenWrt:~# cat /etc/openvpn/my-vpn.conf 
    dev tun
    client
    #proto tcp
    proto udp
    remote id2ndr.toulan.fr 1195
    resolv-retry infinite
    nobind
    persist-key
    persist-tun
    ca /etc/openvpn/class3.crt
    cert /etc/openvpn/Id2ndR.crt
    key /etc/openvpn/Id2ndR.key
    comp-lzo no
    verb 3
    root@OpenWrt:/etc/openvpn# wget http://www.cacert.org/certs/class3.crt
    root@OpenWrt:~# vi /etc/openvpn/Id2ndR.crt
    root@OpenWrt:~# vi /etc/openvpn/Id2ndR.key
    root@OpenWrt:~# uci set openvpn.custom_config.enabled=1
    root@OpenWrt:~# uci commit
    root@OpenWrt:~# /etc/init.d/openvpn start
    root@OpenWrt:~# logread
    [..]
    Sat Dec  6 19:35:15 2014 daemon.warn openvpn(custom_config)[25584]: WARNING: file '/etc/openvpn/Id2ndR.key' is group or others accessible
    Sat Dec  6 19:35:15 2014 daemon.notice netifd: Interface 'wan_vpn' is disabled
    Sat Dec  6 19:35:15 2014 daemon.notice openvpn(custom_config)[25584]: Socket Buffers: R=[163840->131072] S=[163840->131072]
    Sat Dec  6 19:35:15 2014 daemon.notice openvpn(custom_config)[25584]: UDPv4 link local: [undef]
    Sat Dec  6 19:35:15 2014 daemon.notice openvpn(custom_config)[25584]: UDPv4 link remote: [AF_INET]91.224.149.109:1195
    Sat Dec  6 19:35:15 2014 daemon.notice openvpn(custom_config)[25584]: TLS: Initial packet from [AF_INET]91.224.149.109:1195, sid=2e0c718b e9ec8be6
    Sat Dec  6 19:35:15 2014 daemon.notice openvpn(custom_config)[25584]: VERIFY OK: depth=1, O=CAcert Inc., OU=http://www.CAcert.org, CN=CAcert Class 3 Root
    Sat Dec  6 19:35:15 2014 daemon.notice openvpn(custom_config)[25584]: VERIFY OK: depth=0, CN=id2ndr.toulan.fr
    Sat Dec  6 19:35:16 2014 daemon.notice openvpn(custom_config)[25584]: Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
    Sat Dec  6 19:35:16 2014 daemon.notice openvpn(custom_config)[25584]: Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
    Sat Dec  6 19:35:16 2014 daemon.notice openvpn(custom_config)[25584]: Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
    Sat Dec  6 19:35:16 2014 daemon.notice openvpn(custom_config)[25584]: Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
    Sat Dec  6 19:35:16 2014 daemon.notice openvpn(custom_config)[25584]: Control Channel: TLSv1.0, cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA, 2048 bit RSA
    Sat Dec  6 19:35:16 2014 daemon.notice openvpn(custom_config)[25584]: [id2ndr.toulan.fr] Peer Connection Initiated with [AF_INET]91.224.149.109:1195
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: SENT CONTROL [id2ndr.toulan.fr]: 'PUSH_REQUEST' (status=1)
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 91.224.149.254,route 10.9.0.0 255.255.255.0,topology net30,ping 30,ping-restart 100,ifconfig 10.9.0.6 10.9.0.5'
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: OPTIONS IMPORT: timers and/or timeouts modified
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: OPTIONS IMPORT: --ifconfig/up options modified
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: OPTIONS IMPORT: route options modified
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: TUN/TAP device tun0 opened
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: TUN/TAP TX queue length set to 100
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: /sbin/ifconfig tun0 10.9.0.6 pointopoint 10.9.0.5 mtu 1500
    Sat Dec  6 19:35:18 2014 daemon.notice openvpn(custom_config)[25584]: /sbin/route add -net 91.224.149.109 netmask 255.255.255.255 gw 192.168.0.1
    
  • Nat via le VPN : inspiré de http://wiki.openwrt.org/doc/howto/vpn.server.openvpn.tun Use-Case 3
    • Dans Luci, Network > Interfaces : créer une interface nommée wan_vpn exploitant l'interface tun0, en client dhcp
    • Dans Luci, Network > Firewall : créer une zone wan_vpn avec l'interface wan_vpn en activant Masquerading
    • Dans Luci, Network > Firewall : supprimer la zone lan existante. Créer la zone lan avec le forward vers la zone wan_vpn
    • Depuis un PC derrière le routeur : traceroute google.fr doit sortir par h7.tetaneutral.net (4ème nœuds chez moi, à cause de la VM)
Résultats :
  • j'ai mesuré environ 70% d'utilisation CPU sur le routeur pour faire passer 17 méga. Ceci est cohérent avec Benchmark_VPN.
  • en 4G, avec une SIM Red, je fais passé en général 6 méga down / 1 méga up (mais parfois beaucoup plus)