20/04/2010

OpenWRT, Xen et ipv6

[ openwrt xen route ipv6 ]

Dans un précédent billet, je décrivais ma configuration xen. Il ne me manquait qu'une seule chose: l'ipv6. Je dois bien avouer que ça ne s'est pas fait en un jour.

J'ai commencé par configurer mon routeur:

root@fonera# route -A inet6 add 2001:470:ca75:100::/64 gw 2001:470:ca75:20:224:1ff:fe0f:f84c

2001:470:ca75:100::/64 est le réseau dédié aux hosts xen et 2001:470:ca75:20:224:1ff:fe0f:f84c l'ipv6 du dongle wifi du portable. Qui dit routage dit forwarding:

root@d531# grep forwarding= /etc/sysctl.conf
net.ipv6.conf.all.forwarding=1

Et pour éviter un message désagréable au boot:

root@d531# echo 'ipv6' >> /etc/modules

J'ai cru avoir une bonne idée en utilisant eth0 (qui me sert très peu) mais c'est vraiment une très mauvaise idée:

root@d531# tail -n 8 /etc/network/interfaces
auto eth0
iface eth0 inet static
    address 192.168.1.116
    netmask 255.255.255.0
iface eth0 inet6 static
    address 2001:470:ca75:100::1
    netmask 64

root@d531# ifconfig eth0 | grep inet6
      adr inet6: 2001:470:ca75:100::1/64 Scope:Global

root@d531# ping6 -c 1 -W 1 2001:470:ca75:100::1
PING 2001:470:ca75:100::1(2001:470:ca75:100::1) 56 data bytes

--- 2001:470:ca75:100::1 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

L'absence d'adresse lien-local ne doit pas être innocente dans cette affaire. Une (lllooonnnggggguuuuueeee) série de ping, reboot, man, google, ifup/ifdown plus tard, une idée me traverse la tête: pourquoi ne pas utiliser une interface virtuelle ?

root@d531# tail -n 8 /etc/network/interfaces
auto dummy0
iface dummy0 inet static
  address 10.0.0.1
  netmask 255.255.255.0
iface dummy0 inet6 static
  address 2001:470:ca75:100::1
  netmask 64

root@d531# ifconfig dummy0 | grep inet6
      adr inet6: 2001:470:ca75:100::1/64 Scope:Global
      adr inet6: fe80::9082:a4ff:fe06:92bc/64 Scope:Lien

root@d531# ping6 -c 1 -W 1 2001:470:ca75:100::1
PING 2001:470:ca75:100::1(2001:470:ca75:100::1) 56 data bytes
64 bytes from 2001:470:ca75:100::1: icmp_seq=1 ttl=64 time=0.030 ms

--- 2001:470:ca75:100::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.030/0.030/0.030/0.000 ms

root@linuto# ping6 -n -c 1 2001:470:ca75:100::1
PING6(56=40+8+8 bytes) 2001:470:ca75:10:214:bff:fe80:337b --> 2001:470:ca75:100::1
16 bytes from 2001:470:ca75:100::1, icmp_seq=0 hlim=63 time=7.855 ms

--- 2001:470:ca75:100::1 ping6 statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 7.855/7.855/7.855/nan ms

It works! Passons à la configuration de xen. Le script vif-route ne prend pas en compte l'ipv6. Heureusement, je ne suis pas seul: http://notes.benv.junerules.com/all/software/xen-and-routed-ipv6/.

J'en profite pour proposer une version perless ici. On précise à xen qu'on utilise une autre interface qu'eth0:

root@d531# grep '\-route' /etc/xen/xend-config.sxp
(network-script 'network-route netdev=dummy0')
(vif-script     'vif-route netdev=dummy0')

Un dernier reboot pour vérifier que le tout survit à un redémarrage et c'est parti:

root@d531# grep vif /etc/xen/openwrt.bsdsx.fr.cfg 
vif         = [ 'ip=10.0.0.33 2001:470:ca75:100::33,mac=00:16:3E:6D:BB:94' ]

root@d531# xm create -c openwrt.bsdsx.fr.cfg
[ snip boot ]
root@OpenWrt:/# ifconfig br-lan|grep inet6
      inet6 addr: 2001:470:ca75:100::33/64 Scope:Global
      inet6 addr: fe80::ac65:afff:fed8:dcc4/64 Scope:Link

Et ça marche ?

root@linutop# traceroute6 -n  2001:470:ca75:100::33
traceroute6 to 2001:470:ca75:100::33 (2001:470:ca75:100::33) from 2001:470:ca75:10:214:bff:fe80:337b, 64 hops max, 12 byte packets
 1  2001:470:ca75:10::1  1.761 ms  1.73 ms  1.324 ms
 2  2001:470:ca75:20:224:1ff:fe0f:f84c  4.317 ms  9.467 ms  10.127 ms
 3  *^C

Hum, pas trop. Un coup de tcpdump plus tard et je me rends compte qu'il manque une route par défaut sur l'invité:

root@OpenWrt:/# ip -6 ro add default via 2001:470:ca75:100::1
root@OpenWrt:/# ping6 -c 1 www.kame.net
PING www.kame.net (2001:200:0:8002:203:47ff:fea5:3085): 56 data bytes
64 bytes from 2001:200:0:8002:203:47ff:fea5:3085: seq=0 ttl=52 time=314.763 ms

--- www.kame.net ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 314.763/314.763/314.763 ms

Un dernier tour sur http://wiki.openwrt.org/doc/uci/network pour enregistrer la route:

root@OpenWrt:/# tail -n 4 /etc/config/network 
config 'route6'
    option 'interface' 'lan'
    option 'target' 'default'
    option 'gateway' '2001:470:ca75:100::1'

Et voilà, c'est bon, servez chaud. Bon appétit.

0 commentaire(s)

Nom :
URL (optionel) :
Écrire ici: "Je conchie sur les pourriels"
Commentaires :

Pages :