Skip to content

Commit d0a0973

Browse files
Naredula Janardhana ReddyAbhi
authored andcommitted
Bug 14120: Enabling SNAT for all the public NICs.
Summary of changes: - snat flag is set to true if it is first ip of the NIC. reviewed-by: Abhi
1 parent 452fc54 commit d0a0973

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎patches/systemvm/debian/config/root/ipassoc.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@ add_routing() {
208208
return 0;
209209
}
210210
add_snat() {
211+
local pubIp=$1
212+
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
211213
if [ "$sflag" == "0" ]
212214
then
215+
logger -t cloud "$(basename $0):Remove SourceNAT $pubIp on interface $ethDev if it is present"
216+
sudo iptables -t nat -D POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;
213217
return 0;
214218
fi
215219

216-
local pubIp=$1
217-
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
218220
logger -t cloud "$(basename $0):Added SourceNAT $pubIp on interface $ethDev"
219221
sudo iptables -t nat -D POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;
220222
sudo iptables -t nat -A POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,10 @@ public int compare(PublicIpAddress o1, PublicIpAddress o2) {
23352335

23362336
boolean add = (ipAddr.getState() == IpAddress.State.Releasing ? false : true);
23372337
boolean sourceNat = ipAddr.isSourceNat();
2338+
/* enable sourceNAT for the first ip of the public interface */
2339+
if (firstIP) {
2340+
sourceNat = true;
2341+
}
23382342
String vlanId = ipAddr.getVlanTag();
23392343
String vlanGateway = ipAddr.getGateway();
23402344
String vlanNetmask = ipAddr.getNetmask();

0 commit comments

Comments
 (0)