26juin 2010
Xen utilisation de l'IPv6 vif-route
23:54 - Par Mohamed YACOUBI - Xen
Mon bloc IPv6 étant enfin routé correctement, je me suis attelé à la configuration de ce dernier sur le Dom0 et DomU Xen.
Ma configuration Xen étant à l'origine en bridge et disposant d'un bloc routé vers mon serveur, j'ai donc dût basculer ma configuration Xen en mode route. (vif-route)
Bien entendu à l'instar du mode bridge, le mode route n'est pas compatible IPv6 ...
Voici deux patch à appliquer (compatible Xen-4) ainsi qu'un exemple de configuration (Gentoo).
1) Dom0
- vif-common
--- vif-common.sh~ 2010-04-07 18:12:04.000000000 +0200 +++ vif-common.sh 2010-06-26 23:08:38.000000000 +0200 @@ -14,7 +14,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # - +# IPv6 Patched by Timeuhmeuh dir=$(dirname "$0") . "$dir/xen-hotplug-common.sh" @@ -135,6 +135,17 @@ ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed -n '1 s,/.*,,p' } +## +# ip6_of interface +# +# Print the IPv6 address currently in use at the given interface, or nothing if +# the interface is not up. +# +ip6_of() +{ + ip -6 addr show dev "$1" scope global | awk -F'[ |/]' '/inet6 (([0-9a-f]+:*)+)/ { print $6 } ' | awk '/::/ {print $1}' +} + ## # dom0_ip @@ -156,3 +167,38 @@ fi echo "$result" } + +## +# dom0_ip6 +# +# Print the IPv6 address of the interface in dom0 through which we are routing. +# This is the IPv6 address on the interface specified as "netdev" as a parameter +# to these scripts, or eth0 by default. This function will call fatal if no +# such interface could be found. # +dom0_ip6() +{ + local nd=${netdev:-eth0} + local result=$(ip6_of "$nd") + if [ -z "$result" ]; then + echo "" + else + echo "$result" + fi +} + +## +# is_ip6 +# +# Verifing IPv6 address +# +is_ipv6() +{ +case "$1" in + *:*:*) + echo "yes" + ;; + *) + echo "" +esac +}
- vif-route
--- vif-route~ 2010-04-07 18:12:04.000000000 +0200 +++ vif-route 2010-06-26 23:12:45.000000000 +0200 @@ -18,17 +18,24 @@ # Read from the store: # ip list of IP networks for the vif, space-separated (default given in # this script). +# +# IPv6 Patched by Timeuhmeuh - http://blog.yacoubi.fr #============================================================================ dir=$(dirname "$0") . "$dir/vif-common.sh" main_ip=$(dom0_ip) +main_ip6=$(dom0_ip6) case "$command" in online) + log info "[vif-route] online request, ip ${ip} with main_ip ${main_ip} and main_ip6 ${main_ip6} for $vif." ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up - echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp + if [ ! -z "${main_ip6}" ]; then + ip -6 addr add ${main_ip6} dev ${vif} + fi + echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp ipcmd='add' cmdprefix='' ;; @@ -43,7 +50,16 @@ # If we've been given a list of IP addresses, then add routes from dom0 to # the guest using those addresses. for addr in ${ip} ; do - ${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip} + result=$(is_ipv6 "${addr}") + if [ -z "${result}" ] ; then + result=`${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip} 2>&1` + log info "[vif-route] Result: ${result}" + else + log info "[vif-route] Adding IPv6 address ${addr} with src ${main_ip6} for $vif." + result=`${cmdprefix} ip -6 route ${ipcmd} ${addr} dev ${vif} src ${main_ip6} 2>&1` + log info "[vif-route] Result: ${result}" + fi +# ${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip} done fi
- /etc/conf.d/net
config_eth0=( "192.168.0.1/24" "2001:758:f00:340:192:168:0:12/64" "2001:758:5312::/48" )
- /etc/xen/domU
vif = [ 'ip=2001:758:5312::2 192.168.0.10' ]
2) Dom0
- /etc/conf.d/net
config_eth0=( "192.168.0.2/24" "2001:758:5312::2/48" ) routes_eth0=( "default gw 192.168.0.1" "default via 2001:758:5312::" )
Patch :
Lien utile : xen-and-routed-ipv6