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
This commit is contained in:
Naredula Janardhana Reddy 2012-03-06 13:11:36 +05:30 committed by Abhi
parent 452fc54c0e
commit d0a09732d2
2 changed files with 8 additions and 2 deletions

View File

@ -208,13 +208,15 @@ add_routing() {
return 0;
}
add_snat() {
local pubIp=$1
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
if [ "$sflag" == "0" ]
then
logger -t cloud "$(basename $0):Remove SourceNAT $pubIp on interface $ethDev if it is present"
sudo iptables -t nat -D POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;
return 0;
fi
local pubIp=$1
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
logger -t cloud "$(basename $0):Added SourceNAT $pubIp on interface $ethDev"
sudo iptables -t nat -D POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;
sudo iptables -t nat -A POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;

View File

@ -2335,6 +2335,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
boolean add = (ipAddr.getState() == IpAddress.State.Releasing ? false : true);
boolean sourceNat = ipAddr.isSourceNat();
/* enable sourceNAT for the first ip of the public interface */
if (firstIP) {
sourceNat = true;
}
String vlanId = ipAddr.getVlanTag();
String vlanGateway = ipAddr.getGateway();
String vlanNetmask = ipAddr.getNetmask();