Helllo,
I'm trying to configure SNAT for my virtual machines, but I'm unable to for some reason I don't really understand.
This is how I've configured the interfaces file:
On my windows machine I've got:
iptables looks correct to my mind:
And vmbr0 is the main interface facing the internet:
So what I find really weird about it is that the return traffic isn't being received by the virtual machine. So when run a tcpdump on vmbr0 while pinging an external server from the virtual machines, I get the reply packages, but the VM never sees it. I would have expected the SNAT rule to be stateful, of course, but something is blocking the traffic and I'm not sure what.
While running ping form on the VM:
Any ideas how I can further debug this?
Thanks!
EDIT:
I forgot to mention that ipv4 forwarding is also activated:
I'm trying to configure SNAT for my virtual machines, but I'm unable to for some reason I don't really understand.
This is how I've configured the interfaces file:
Code:
auto vmbr1
iface vmbr1 inet static
address 10.10.111.1
netmask 255.255.255.0
bridge-ports none
bridge-stp off
bridge-fd 0
post-up iptables -t nat -A POSTROUTING -s '10.10.111.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.111.0/24' -o vmbr0 -j MASQUERADE
10.10.111.10/24
iptables looks correct to my mind:
Code:
root@pve1:~# iptables -t nat -vnL --line-numbers
Chain PREROUTING (policy ACCEPT 22394 packets, 4195K bytes)
num pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 1138 packets, 70431 bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1081 packets, 67494 bytes)
num pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 1081 packets, 67494 bytes)
num pkts bytes target prot opt in out source destination
1 230 15281 MASQUERADE all -- * vmbr0 10.10.111.0/24 0.0.0.0/0
And vmbr0 is the main interface facing the internet:
Code:
root@pve1:~# ip a show vmbr0
3: vmbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 70:71:bc:83:38:14 brd ff:ff:ff:ff:ff:ff
inet 192.168.111.16/24 brd 192.168.111.255 scope global dynamic vmbr0
So what I find really weird about it is that the return traffic isn't being received by the virtual machine. So when run a tcpdump on vmbr0 while pinging an external server from the virtual machines, I get the reply packages, but the VM never sees it. I would have expected the SNAT rule to be stateful, of course, but something is blocking the traffic and I'm not sure what.
While running ping form on the VM:
Code:
root@pve1:~# tcpdump -i vmbr0 icmp -nn -vvv
tcpdump: listening on vmbr0, link-type EN10MB (Ethernet), capture size 262144 bytes
12:03:55.332153 IP (tos 0x0, ttl 127, id 13584, offset 0, flags [none], proto ICMP (1), length 60)
192.168.111.16 > public_ip: ICMP echo request, id 1, seq 38, length 40
12:03:55.335972 IP (tos 0x0, ttl 58, id 55309, offset 0, flags [none], proto ICMP (1), length 60)
public_ip > 192.168.111.16: ICMP echo reply, id 1, seq 38, length 40
12:04:00.029916 IP (tos 0x0, ttl 127, id 13585, offset 0, flags [none], proto ICMP (1), length 60)
192.168.111.16 > public_ip: ICMP echo request, id 1, seq 39, length 40
12:04:00.033527 IP (tos 0x0, ttl 58, id 55541, offset 0, flags [none], proto ICMP (1), length 60)
public_ip > 192.168.111.16: ICMP echo reply, id 1, seq 39, length 40
12:04:05.029182 IP (tos 0x0, ttl 127, id 13586, offset 0, flags [none], proto ICMP (1), length 60)
Any ideas how I can further debug this?
Thanks!
EDIT:
I forgot to mention that ipv4 forwarding is also activated:
Code:
root@pve1:~# sysctl -a | grep ip_forward
net.ipv4.ip_forward = 1
Last edited: