Skip to content

Commit 9e4052a

Browse files
committed
Fix hairpin SNAT when using static NAT IP for for dest
1 parent 22d1890 commit 9e4052a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

systemvm/debian/opt/cloud/bin/configure.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,9 @@ def processStaticNatRule(self, rule):
937937
self.fw.append(["filter", "",
938938
"-A FORWARD -i %s -o eth0 -d %s -m state --state NEW -j ACCEPT " % (device, rule["internal_ip"])])
939939

940-
# Configure the hairpin nat
941-
self.fw.append(["nat", "front",
942-
"-A PREROUTING -d %s -i eth0 -j DNAT --to-destination %s" % (rule["public_ip"], rule["internal_ip"])])
943-
944-
self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o eth0 --to-source %s" %
945-
(self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getGuestIp())])
940+
# Configure the hairpin snat
941+
self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o %s --to-source %s" %
942+
(self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getDeviceByIp(rule["internal_ip"]), self.getGuestIp())])
946943

947944

948945
class IpTablesExecutor:

0 commit comments

Comments
 (0)