télécharger 84.35 Kb.
|
VTUN (Virtual Tunnel) entre Equinix-Zurich et PSE-Lausanne Oussama Hammami, 2010-08-04 Switzernet Ce document nous sert de memo pour mettre en place un tunnel virtuel sur un serveur et des clients Debian ETCH. Principe de fonctionnementOn va donc monter un tunnel entre deux machines PSE-L et EQX-Z, c'est-à-dire qu'on va créer une interface virtuelle qui va manipuler nos paquets avant de les envoyer sur l'interface physique. Quand la machine PSE-L voudra parler à la machine EQX-Z, elle enverra ses données vers l'interface tunX (tun0, tun1 …) qui fera la compression, le chiffrement,… et les enverra à EQX-Z via l'interface physique. De l'autre côté c'est le même principe, on reçoit les données sur l'interface physique, elles sont remontées à l'interface virtuelle qui fait la décompression, le déchiffrement,… et renvoie ça à l'application. L'avantage c'est qu'au niveau applicatif, il n'y a rien à changer. On joint la machine distante en utilisant l'IP affectée au tunnel. ArchitectureOn travaillera donc avec deux machines ; PSE-L : qui se trouve chez nous à PSE-B à Lausanne. EQX-Z : qui se trouve à Equinix Zurich. ![]() Il n'est pas question de routage, c'est-à-dire que le tunnel va permettre à PSE-L de communiquer directement sans routage avec EQX-Z. Donc on a la machine PSE-L qui a l'IP 217.X.Y.6 (eth0) et 212.A.B.107 (eth1) et la machine EQX-Z qui a l'IP 217.X.Y.5. Ici toutes les adresses sont des adresses Publiques et on n’est pas derrière une NAT (on a obtenu ces adresses Publiques depuis notre connexion VTX à PSE-A grâce à cette architecture) Pour permettre l’établissement du tunnel (authentification) entre le client vtun PSE-L et le serveur vtun EQX-Z, il faut ajouter une route uniquement pour ce serveur (EQX-Z) en utilisant le default Gateway du l’interface eth1 : # route add -host 217.X.Y.5 gw 212.A.B.1 Vous aurez besoin du driver tun dans votre noyau (modprobe tun ou Device Drivers/Network device support/Universal TUN/TAP device driver support) et du paquet vtun. Installation & configurationExécuter ces commandes dans les deux machines (client serveur): # aptitude update # aptitude install uml-utilities # aptitude install bridge-utils # tunctl -u root -t tap0 # ifconfig tap0 0.0.0.0 promisc up # aptitude install vtun # modprobe tun Serveur vtun: EQX-Z/etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 allow-hotplug eth0 iface eth0 inet manual auto br0 iface br0 inet static address 217.X.Y.5 netmask 255.255.255.224 gateway 217.X.Y.1 bridge_ports eth0 /etc/vtund.conf options { port 5000; syslog daemon; # Path to various programs ifconfig /sbin/ifconfig; route /sbin/route; firewall /sbin/iptables; ip /sbin/ip; } default { compress no; encrypt no; speed 0; } My-ip-tunnel { passwd your-password; type ether; proto udp; keepalive yes; compress no; encrypt yes; up { ifconfig "%% up"; program "/usr/sbin/brctl addif br0 %%"; }; down { # Connection is Down ifconfig "%% down"; }; } /etc/default/vtun # Defaults for vtun initscript # sourced by /etc/init.d/vtun # Created by the maintainer scripts # # This is a POSIX shell fragment # # Should the standalone server be started? RUN_SERVER=yes SERVER_ARGS="-P 5000" Vous pouvez maintenant démarrer le serveur : # ifconfig br0 up # vtund -s Si tout a été configuré correctement, nous verrons la suite des résultats sur les deux interfaces (br0 et tap0): # ifconfig br0 br0 Link encap:Ethernet HWaddr 00:24:1d:b6:07:ee inet addr:217.X.Y.5 Bcast:217.X.Y.31 Mask:255.255.255.224 inet6 addr: fe80::224:1dff:feb6:7ee/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19675720 errors:0 dropped:0 overruns:0 frame:0 TX packets:10061532 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1331973430 (1.2 GiB) TX bytes:3314605535 (3.0 GiB) # ifconfig tap0 tap0 Link encap:Ethernet HWaddr 00:ff:16:25:59:a7 inet6 addr: fe80::2ff:16ff:fe25:59a7/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:107 errors:0 dropped:0 overruns:0 frame:0 TX packets:206990 errors:0 dropped:0 overruns:192101 carrier:0 collisions:0 txqueuelen:500 RX bytes:11999 (11.7 KiB) TX bytes:265766330 (253.4 MiB) Si vous avez besoin de voir l'état actuel de l'interface du Bridge, vous pouvez utiliser l'outil brctl # brctl show br0 bridge name bridge id STP enabled interfaces br0 8000.00241db607ee no eth0 tap0 N’hésitez pas de vérifier le log en cas de problème. # tail -f /var/log/daemon.log Client vtun: PSE-L/etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface ### auto eth0 allow-hotplug eth0 iface eth0 inet manual ### auto br0 iface br0 inet static address 217.X.Y.6 netmask 255.255.255.224 bridge_ports eth0 # The scondary network interface ####################################### auto eth1 allow-hotplug eth1 iface eth1 inet static address 212.A.B.107 netmask 255.255.255.248 network 212.A.B.104 broadcast 212.A.B.111 gateway 212.A.B.105 dns-nameservers 212.A.B.98 /etc/vtund.conf bbcs-adsl-c008-p107:~# cat /etc/vtund.conf options { port 5000; syslog daemon; # Path to various programs ifconfig /sbin/ifconfig; route /sbin/route; firewall /sbin/iptables; ip /sbin/ip; } My-ip-tunnel { passwd yourpassword; type ether; proto udp; keepalive yes; compress no; encrypt yes; up { ifconfig "%% up"; program "/usr/sbin/brctl addif br0 %%"; }; down { # Connection is Down ifconfig "%% down"; }; } /etc/default/vtun # Defaults for vtun initscript # sourced by /etc/init.d/vtun # Created by the maintainer scripts # # This is a POSIX shell fragment # # Should the standalone server be started? # RUN_SERVER=no # SERVER_ARGS="-P 5000" # Client sessions to start. Up to ten instances can be configured. # # Session name # CLIENT0_NAME=viper # # Destination host # CLIENT0_HOST=vtun-server.somewhere.com.au # # Optional parameters # CLIENT0_ARGS= # # CLIENT1_NAME= # CLIENT1_HOST= # CLIENT1_ARGS= CLIENT0_NAME=My-ip-tunnel CLIENT0_HOST=212.X.Y.5 /etc/init.d/vtun-star ifconfig br0 down route add -host 217.X.Y.5 gw 212.A.B.105 ifconfig br0 up #route del -net 0.0.0.0 gw 217.X.Y.1 vtund My-ip-iptunnel 217.X.Y.5 #route -n > start-vtun.log #brctl show br0 >> start-vtun.log #tail -f /var/log/daemon.log Pour démarrer le client vous pouvez exécuter le fichier /etc/init.d/vtun-star donc il faux ajouter les droits d’exécution à ce dernier : # chmod +x /etc/init.d/vtun-star # /etc/init.d/vtun-star Pour que le redémarrage du ce serveur se fait correctement il faut remplacer vtun par ce script dans la liste de démarrage en utilisant par exemple rcconf. # ifconfig br0 Link encap:Ethernet HWaddr 00:13:49:aa:9d:34 inet addr:217.X.Y.6 Bcast:217.X.Y.31 Mask:255.255.255.224 inet6 addr: fe80::213:49ff:feaa:9d34/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2378 errors:0 dropped:0 overruns:0 frame:0 TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:136269 (133.0 KiB) TX bytes:978 (978.0 B) eth0 Link encap:Ethernet HWaddr 00:13:49:aa:9d:34 inet6 addr: fe80::213:49ff:feaa:9d34/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:109 errors:0 dropped:0 overruns:0 frame:0 TX packets:2742 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12509 (12.2 KiB) TX bytes:416600 (406.8 KiB) Interrupt:18 Base address:0xce00 eth1 Link encap:Ethernet HWaddr 00:23:54:b7:a4:7e inet addr:212.A.B.107 Bcast:212.A.B.111 Mask:255.255.255.248 inet6 addr: fe80::223:54ff:feb7:a47e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3084 errors:0 dropped:0 overruns:0 frame:0 TX packets:447 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:577916 (564.3 KiB) TX bytes:58606 (57.2 KiB) Interrupt:219 Base address:0xc000 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:69 errors:0 dropped:0 overruns:0 frame:0 TX packets:69 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5404 (5.2 KiB) TX bytes:5404 (5.2 KiB) tap0 Link encap:Ethernet HWaddr 00:ff:54:2c:6e:90 inet6 addr: fe80::2ff:54ff:fe2c:6e90/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2755 errors:0 dropped:0 overruns:0 frame:0 TX packets:116 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500 RX bytes:417434 (407.6 KiB) TX bytes:13019 (12.7 KiB) # brctl show br0 bridge name bridge id STP enabled interfaces br0 8000.001349aa9d34 no eth0 tap0 # tail -f /var/log/daemon.log Aug 4 16:51:23 bbcs-adsl-c008-p107 vtund[2538]: VTun client ver 3.X 01/14/2009 started Aug 4 16:51:23 bbcs-adsl-c008-p107 vtund[2538]: Connecting to 217.X.Y.5 Aug 4 16:51:23 bbcs-adsl-c008-p107 vtund[2538]: Use SSL-aware challenge/response Aug 4 16:51:23 bbcs-adsl-c008-p107 vtund[2538]: Remote Server sends Aug 4 16:51:23 bbcs-adsl-c008-p107 vtund[2538]: Session iptunnel[217.X.Y.5]opened Aug 4 16:51:24 bbcs-adsl-c008-p107 vtund[2538]: UDP connection initialized Aug 4 16:51:24 bbcs-adsl-c008-p107 vtund[2538]: Blowfish-128-ECB encryption initialized Testes de confirmationVoici le résultat d’une trace route (tracert) depuis le client vtun (Lausanne) à une machine derrière le tunnel à Zurich # tracert -d 217.X.Y.4 traceroute to 217.X.Y.4 (217.X.Y.4), 30 hops max, 40 byte packets 1 217.168.45.4 18.624 ms 18.958 ms 19.576 Résultat d’une trace route (tracert) depuis le serveur vtun (Zurich) à une machine derrière le client vtun (+switch) à Lausanne # tracert -d 217.X.Y.7 traceroute to 217.X.Y.7 (217.X.Y.7), 30 hops max, 40 byte packets 1 (217.X.Y.7) 29.238 ms 30.938 ms 32.612 ms Résultat d’une trace route (tracert) depuis une machine à Lausanne derrière le client vtun (+switch) à une machine à Zurich $ tracert -d 217.X.Y.4 Tracing route to 217.X.Y.4 over a maximum of 30 hops 1 27 ms 13 ms 13 ms 217.X.Y.4 Dans le serveur, vous pouvez lancez une capture pour le port 5000 # ngrep -qpl -W byline "" udp port 5000 eth0: no IPv4 address assigned: Cannot assign requested address interface: eth0 filter: (ip or ip6) and ( udp port 5000 ) U 217.X.Y.5:5000 -> 212.A.B.107:39897 .@.-...T.&.e...>.?l...v..S.../.wd....;:.a...w._XR..:.....+...{F.`. U 217.X.Y.5:5000 -> 212.A.B.107:39897 .@.-...T.&.e...>.?l...v..S.../.wd....;:.a...w._XR..:.....+...{F.`. Statistique PingPING depuis le client vtun (Lausanne) à une machine derrière le tunnel à Zurich # ping 217.X.Y.4 PING 217.X.Y.4 (217.X.Y.4) 56(84) bytes of data. 64 bytes from 217.X.Y.4: icmp_seq=1 ttl=64 time=29.8 ms 64 bytes from 217.X.Y.4: icmp_seq=2 ttl=64 time=13.7 ms 64 bytes from 217.X.Y.4: icmp_seq=3 ttl=64 time=14.0 ms 64 bytes from 217.X.Y.4: icmp_seq=4 ttl=64 time=14.0 ms 64 bytes from 217.X.Y.4: icmp_seq=5 ttl=64 time=14.6 ms 64 bytes from 217.X.Y.4: icmp_seq=6 ttl=64 time=14.0 ms 64 bytes from 217.X.Y.4: icmp_seq=7 ttl=64 time=14.1 ms 64 bytes from 217.X.Y.4: icmp_seq=8 ttl=64 time=13.5 ms 64 bytes from 217.X.Y.4: icmp_seq=9 ttl=64 time=14.2 ms 64 bytes from 217.X.Y.4: icmp_seq=10 ttl=64 time=13.7 ms 64 bytes from 217.X.Y.4: icmp_seq=11 ttl=64 time=13.9 ms 64 bytes from 217.X.Y.4: icmp_seq=12 ttl=64 time=14.1 ms 64 bytes from 217.X.Y.4: icmp_seq=13 ttl=64 time=15.3 ms 64 bytes from 217.X.Y.4: icmp_seq=14 ttl=64 time=14.8 ms 64 bytes from 217.X.Y.4: icmp_seq=15 ttl=64 time=14.0 ms 64 bytes from 217.X.Y.4: icmp_seq=16 ttl=64 time=13.9 ms 64 bytes from 217.X.Y.4: icmp_seq=17 ttl=64 time=13.6 ms 64 bytes from 217.X.Y.4: icmp_seq=18 ttl=64 time=13.6 ms 64 bytes from 217.X.Y.4: icmp_seq=19 ttl=64 time=14.2 ms 64 bytes from 217.X.Y.4: icmp_seq=20 ttl=64 time=13.2 ms ^C --- 217.X.Y.4 ping statistics --- 20 packets transmitted, 20 received, 0% packet loss, time 19074ms rtt min/avg/max/mdev = 13.276/14.856/29.827/3.465 ms PING depuis le client vtun (Lausanne) à machine derrière le client vtun (+switch) à Lausanne # ping 217.X.Y.7 PING 217.X.Y.7 (217.X.Y.7) 56(84) bytes of data. 64 bytes from 217.X.Y.7: icmp_seq=1 ttl=128 time=0.147 ms 64 bytes from 217.X.Y.7: icmp_seq=2 ttl=128 time=0.119 ms 64 bytes from 217.X.Y.7: icmp_seq=3 ttl=128 time=0.117 ms 64 bytes from 217.X.Y.7: icmp_seq=4 ttl=128 time=0.111 ms 64 bytes from 217.X.Y.7: icmp_seq=5 ttl=128 time=0.123 ms 64 bytes from 217.X.Y.7: icmp_seq=6 ttl=128 time=0.118 ms 64 bytes from 217.X.Y.7: icmp_seq=7 ttl=128 time=0.122 ms 64 bytes from 217.X.Y.7: icmp_seq=8 ttl=128 time=0.119 ms 64 bytes from 217.X.Y.7: icmp_seq=9 ttl=128 time=0.115 ms 64 bytes from 217.X.Y.7: icmp_seq=10 ttl=128 time=0.111 ms 64 bytes from 217.X.Y.7: icmp_seq=11 ttl=128 time=0.116 ms 64 bytes from 217.X.Y.7: icmp_seq=12 ttl=128 time=0.112 ms 64 bytes from 217.X.Y.7: icmp_seq=13 ttl=128 time=0.119 ms 64 bytes from 217.X.Y.7: icmp_seq=14 ttl=128 time=0.111 ms 64 bytes from 217.X.Y.7: icmp_seq=15 ttl=128 time=0.108 ms 64 bytes from 217.X.Y.7: icmp_seq=16 ttl=128 time=0.112 ms 64 bytes from 217.X.Y.7: icmp_seq=17 ttl=128 time=0.108 ms 64 bytes from 217.X.Y.7: icmp_seq=18 ttl=128 time=0.112 ms 64 bytes from 217.X.Y.7: icmp_seq=19 ttl=128 time=0.115 ms 64 bytes from 217.X.Y.7: icmp_seq=20 ttl=128 time=0.109 ms ^C --- 217.X.Y.7 ping statistics --- 20 packets transmitted, 20 received, 0% packet loss, time 18997ms rtt min/avg/max/mdev = 0.108/0.116/0.147/0.010 ms RéférenceConnecting Two Remote Local Networks With Transparent Bridging Technique http://kovyrin.net/2006/04/05/connecting-two-remote-local-networks-with-transparent-bridging/ Vtun Experimentation http://awgtek.blogspot.com/2009/06/vtun-experimentation_17.html Création d'un tunnel chiffré entre deux machines avec vtun http://blog.orniz.org/index.php/post/2010/03/Cr%C3%A9ation-d-un-tunnel-chiffr%C3%A9-entre-deux-machines-avec-vtun Installation d'un VPN avec Vtun http://ot.geneve.ch/ot/IMG/pdf/VPNinstallation-HOWTO1.1.pdf Secure Tunneling between Intranets with VTun http://www.adamolson.com/articles/UnixReview.com%20%20Secure%20Tunneling%20between%20Intranets%20with%20VTun%202000.htm EssaiConfigVTun http://www.nantes-wireless.org/pages/wiki/index.php?pagename=EssaiConfigVTun VTUN The easiest way to create Virtual Tunnels over TCP/IP networks with traffic shaping, compression and encryption. http://vtun.sourceforge.net/ Switzernet infrastructure http://switzernet.com/company/091216-infrastructure/ Architecture and configurations of Equinix Zurich collocation http://switzernet.com/company/091228-equinix-configs/ Transfer des adresses IP public de VTX à PSE-B http://switzernet.com/2/public/100730-vtx-pse-lan/ VPN (Virtual Private Network) pour Equinix http://switzernet.com/company/091127-vpn-equinix/ |
![]() | ![]() | «switchée» ou «commutée» (fabric) : on utilise dans ce cas un commutateur (switch en anglais) Fibre Channel, dont le principe de... | |
![]() | ![]() | ||
![]() | ![]() | ||
![]() | ![]() | ||
![]() | ![]() |