Le 07/08/2011 03:02, Thierry B a écrit :
> Bonsoir,
>
> J'ai installé sur un serveur dédié une debian squeeze avec xen 4, une VM 
> principale qui tourne en mode route avec une IP failover ainsi qu'une autre 
> VM de etst tournant en NAT.
>
> Je voulais donc mixer le mode route et nat, et j'ai effectué la config 
> suivante: 
>
> - contenu de mon xend-config.sxp :
>
> (network-script 'network-route netdev=eth0')
> (vif-script     vif-route)
>
> vu que c'est ma 1ere VM en mode route la plus importante.
>
> Pour la seconde VM en nat, j'ai mis ceci dans le fichier de config:
>
> vif         = [ 'ip=192.168.1.2,mac=00:16:3E:xxxx:xx, script=vif-nat,
> vifname=vif-debianTest' ]
>
> J'ai modifié un peu le script vif-nat :
>
> routing_ip()
> {
>   #echo $(echo $1 | awk -F. '{print $1"."$2"."$3"."$4 + 127}')
>   echo $(echo $1 | awk -F. '{print $1"."$2"."$3"."254}')
> }
>
> pour avoir toujours la même ip statique en gateway pour la VM2, et pour 
> pouvoir mettre cette IP dans la config réseau du domU correspondant.
>
> Je peux pinguer VM2 depuis mon dom0, j'ai internet depuis ma VM2 mais 
> impossible de faire un port mapping.
> On dirait que rien ne forward entre mes interfaces 
>
> Par exemple, je voulais rediriger le port 2222 de mon dom0 vers le 22 de VM2 ;
>
> Voici mes règles  :
>
> # iptables -L -v | more
>
> Chain INPUT (policy DROP 860 packets, 95727 bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>
>    18  2185 ACCEPT     all  --  lo     any     anywhere             anywhere
>
>     8   792 ACCEPT     icmp --  any    any     anywhere             anywhere
>
>  1065 83852 ACCEPT     tcp  --  eth0   any     
> lev92-4-88-164-133-124.fbx.proxad
> .net  anywhere            tcp dpt:ssh
>     5   544 ACCEPT     all  --  eth0   any     anywhere             anywhere
>         state RELATED,ESTABLISHED
>     0     0 ACCEPT     all  --  vif2.0 any     anywhere             anywhere
>
>     0     0 ACCEPT     all  --  vif-debianTest any     anywhere             
> anyw
> here
>
> Chain FORWARD (policy DROP 11 packets, 528 bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>
>  1517  322K ACCEPT     all  --  eth0   any     anywhere             anywhere
>         state RELATED,ESTABLISHED
>    10   496 ACCEPT     all  --  eth0   any     anywhere             
> 88-190-238-1
> 64.rev.dedibox.fr
>  1605  143K ACCEPT     all  --  vif2.0 any     anywhere             anywhere
>
>     0     0 ACCEPT     all  --  vif-xenwinxp any     anywhere             
> anywhe
> re
>     0     0 ACCEPT     all  --  vif-debianTest any     anywhere             
> anyw
> here
>     0     0 ACCEPT     all  --  any    any     anywhere             anywhere
>         state RELATED,ESTABLISHED PHYSDEV match --physdev-out vif-debianTest
>     0     0 ACCEPT     udp  --  any    any     anywhere             anywhere
>         PHYSDEV match --physdev-in vif-debianTest udp spt:bootpc dpt:bootps
>     0     0 ACCEPT     all  --  any    any     anywhere             anywhere
>         state RELATED,ESTABLISHED PHYSDEV match --physdev-out vif-debianTest
>     0     0 ACCEPT     all  --  any    any     xenDebianTest        anywhere
>         PHYSDEV match --physdev-in vif-debianTest
>
>
> Chain OUTPUT (policy ACCEPT 886 packets, 129K bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>
>    24  2946 ACCEPT     all  --  any    lo      anywhere             anywhere
>
>
> # iptables -L -t nat -v | more
> Chain PREROUTING (policy ACCEPT 1265 packets, 132K bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>
>    11   528 DNAT       tcp  --  eth0   any     anywhere             anywhere
>         tcp dpt:2222 to:192.168.1.2:22
>
> Chain POSTROUTING (policy ACCEPT 27 packets, 1850 bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>
>   110  7826 SNAT       all  --  any    eth0    88-190-238-164.rev.dedibox.fr  
> an
> ywhere            to:88.190.238.164
>     0     0 SNAT       all  --  any    any     192.168.0.2          anywhere
>         to:88.190.15.135
>     0     0 SNAT       all  --  any    any     xenDebianTest        anywhere
>         to:88.190.15.135
>
> Chain OUTPUT (policy ACCEPT 21 packets, 1538 bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>
>
> # tcpdump -i eth0 tcp port 2222
> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
> listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
> 19:54:02.662761 IP lev92-4-88-164-133-124.fbx.proxad.net.21384 >
> sd-xxxx.dedibox.fr.2222: Flags [S], seq 2030026446, win 65535, options
> [mss 1460,nop,nop,sackOK], length 0
> 19:54:05.681658 IP lev92-4-88-164-133-124.fbx.proxad.net.21384 >
> sd-xxxx.dedibox.fr.2222: Flags [S], seq 2030026446, win 65535, options
> [mss 1460,nop,nop,sackOK], length 0
> ...
>
> Rien n'est donc forwardé entre eth0 et vif-debianTest
>
> Pourtant :
>
> # cat /proc/sys/net/ipv4/ip_forward
> 1
>
> # cat /proc/sys/net/ipv4/conf/eth0/forwarding
> 1
>
> # cat /proc/sys/net/ipv4/conf/all/forwarding
> 1
>
>
> # cat /etc/sysctl.conf
> net.ipv4.ip_forward=1
> net.ipv4.conf.all.proxy_arp=1
>
>
>  # ifconfig vif-debianTest
>
> vif-debianTest Link encap:Ethernet  HWaddr fe:ff:ff:ff:ff:ff
>           inet adr:192.168.1.254  Bcast:0.0.0.0  Masque:255.255.255.255
>           adr inet6: fe80::fcff:ffff:feff:ffff/64 Scope:Lien
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:3 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:2 errors:0 dropped:3 overruns:0 carrier:0
>           collisions:0 lg file transmission:32
>           RX bytes:196 (196.0 B)  TX bytes:160 (160.0 B)
>
> # ip route show
> 88.190.238.164 dev vif2.0  scope link  src 88.190.15.135
> 192.168.1.2 dev vif-debianTest  scope link  src 192.168.1.254
> 88.190.15.0/24 dev eth0  proto kernel  scope link  src 88.190.15.135
> default via 88.190.15.1 dev eth0
>
>  
> J'ai testé avec mon laptop. Au début ca ne fonctionnait pas non plus, et 
> depuis que j'ai une seule fois redemarré en mode nat par défaut dans le 
> xend-config.sxp, ca marche. Même en remettant le mode route par défaut.
>
> Une idée?
>
> Merci :-)
>
Bonsoir,

Finalement, j'ai trouvé.

J'ai basé ma règle FORWARD, non pas sur l'interface vif, mais sur l'ip
tout simplement :
iptables -A FORWARD -p tcp -m state --state NEW -d 192.168.1.2 --dport
22 -j AC\
CEPT

et hop, ca marche :-)

Merci.

Répondre à