fix: dnat rule add dst restrictions
This commit is contained in:
parent
20c774aee7
commit
7d83693a69
1 changed files with 4 additions and 2 deletions
|
@ -147,9 +147,11 @@ configureNAT () {
|
||||||
ip link set dev "${VM_NET_TAP}" master dockerbridge
|
ip link set dev "${VM_NET_TAP}" master dockerbridge
|
||||||
|
|
||||||
# Add internet connection to the VM
|
# Add internet connection to the VM
|
||||||
|
IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
|
||||||
|
|
||||||
iptables -t nat -A POSTROUTING -o "${VM_NET_DEV}" -j MASQUERADE
|
iptables -t nat -A POSTROUTING -o "${VM_NET_DEV}" -j MASQUERADE
|
||||||
iptables -t nat -A PREROUTING -i "${VM_NET_DEV}" -p tcp -j DNAT --to $VM_NET_IP
|
iptables -t nat -A PREROUTING -i "${VM_NET_DEV}" -d "${IP}" -p tcp -j DNAT --to $VM_NET_IP
|
||||||
iptables -t nat -A PREROUTING -i "${VM_NET_DEV}" -p udp -j DNAT --to $VM_NET_IP
|
iptables -t nat -A PREROUTING -i "${VM_NET_DEV}" -d "${IP}" -p udp -j DNAT --to $VM_NET_IP
|
||||||
|
|
||||||
if (( KERNEL > 4 )); then
|
if (( KERNEL > 4 )); then
|
||||||
# Hack for guest VMs complaining about "bad udp checksums in 5 packets"
|
# Hack for guest VMs complaining about "bad udp checksums in 5 packets"
|
||||||
|
|
Loading…
Reference in a new issue