From e92ce916f34577ca5436aa6d63b00ccb3742e1e1 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com> Date: Sun, 3 Oct 2021 06:25:28 -0300 Subject: [PATCH] network: Remove logic that creates gap for multiple 'source NAT' in VR (#5532) In ACS, when a VPC has more than one public IP and a user tries to use the non `source NAT` IP with some feature/option (like `static NAT`, `port forwarding`, `VPN` and others), ACS adds the public IP (used for the feature/option) as `source NAT` in the `iptables` of the VR. Example: - VPC has one public IP `192.168.0.50` and it is defined as the `source NAT`. - If we assign another public IP `192.168.0.51` to the VPC and use it to execute `port forwarding`, ACS will automatically add `192.168.0.51` as `source NAT` too. Co-authored-by: GutoVeronezi --- .../com/cloud/network/router/CommandSetupHelper.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java index e73a83393f4..4bff1a5187d 100644 --- a/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/main/java/com/cloud/network/router/CommandSetupHelper.java @@ -717,17 +717,10 @@ public class CommandSetupHelper { for (final PublicIpAddress ipAddr : ipAddrList) { final boolean add = ipAddr.getState() == IpAddress.State.Releasing ? false : true; - boolean sourceNat = ipAddr.isSourceNat(); - /* enable sourceNAT for the first ip of the public interface - * For additional public subnet source nat rule needs to be added for vm to reach ips in that subnet - */ - if (firstIP) { - sourceNat = true; - } final String macAddress = vlanMacAddress.get(BroadcastDomainType.getValue(BroadcastDomainType.fromString(ipAddr.getVlanTag()))); - final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, sourceNat, BroadcastDomainType.fromString(ipAddr.getVlanTag()).toString(), ipAddr.getGateway(), + final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, ipAddr.isSourceNat(), BroadcastDomainType.fromString(ipAddr.getVlanTag()).toString(), ipAddr.getGateway(), ipAddr.getNetmask(), macAddress, networkRate, ipAddr.isOneToOneNat()); setIpAddressNetworkParams(ip, network, router);