Forum Discussion

Sharon_Lucas_55's avatar
Sharon_Lucas_55
Icon for Nimbostratus rankNimbostratus
Apr 28, 2010

Problem creating a SNAT

Hi, we're using the F5's iControl SDK to create a Java application that automates configuring the F5 Proxy. Everything is working except for when we try to create a SNAT.

 

 

When using a web browser and the BIG-IP configuration utility GUI, we click on "Local Traffic", hover over "SNATs", and click on "Create". We specify a snat name of snat1, and in the Translation field, we click Automap and then click on Finished.

 

 

To automate this via Java, here's a snippet of our code. There is no exception raised when creating the SNAT, but the SNAT is not created. We have made sure that the SNAT does not exist -- in fact, no SNATs exist on our BIG-IP. But, it does not fail, but does not create the SNAT either. Please advise on what we're doing wrong.

 

 

String snatName = "snat1";

 

 

iControlLocalLBSNATBindingStub m_snat = (iControl.LocalLBSNATBindingStub)

 

new iControl.LocalLBSNATLocator().getLocalLBSNATPort(

 

new java.net.URL(m_endpoint));

 

 

// Removed the code we use to verify that the snat does not already exist

 

 

// Set translation_object to empty string since type is AutoMap

 

iControl.LocalLBSNATTranslation snat_translation =

 

new iControl.LocalLBSNATTranslation(

 

iControl.LocalLBSnatType.SNAT_TYPE_AUTOMAP, "");

 

 

iControl.LocalLBSNATSNATDefinition snat_definition =

 

new iControl.LocalLBSNATSNATDefinition(snat_name, snat_translation);

 

 

iContol LocalLBSNATSNATDefinition[] snats = { snat_definition };

 

 

// Specify null to indicate all addresses

 

// Specify null to indicate all VLANs

 

msnat.create(snats, null, null);

 

 

// Check if the SNAT was really created

 

 

snat_list = m_snat.get_list();

 

boolean snat_created = false;

 

 

for (int i = 0; i < snat_list.length; i++)

 

{

 

if (snat_list.equals(snat_name))

 

{

 

snat_created = true;

 

break;

 

}

 

}

 

 

if (!snat_created)

 

{

 

System.out.println("\nERROR: SNAT " + snat_name +

 

" was not created");

 

}

1 Reply

  • I fiigured this out. Using the following code to set the original_addresses and vlans when creating the SNAT works.

     

     

    // To specify "All addresses", specify "0.0.0.0" for the

     

    // original_address and for the wildmask

     

     

    iControl.LocalLBSNATSNATOriginalAddress snatAddress =

     

    new iControl.LocalLBSNATSNATOriginalAddress(

     

    "0.0.0.0", "0.0.0.0");

     

     

    iControl.LocalLBSNATSNATOriginalAddress[][] snatAddresses =

     

    { { snatAddress } };

     

     

    // To specify all VLANs, set the state to disabled and set the

     

    // VLANFilterList to an empty list

     

     

    String[] vlans = {};

     

     

    iControl.CommonVLANFilterList vlanFilterList =

     

    new iControl.CommonVLANFilterList(

     

    iControl.CommonEnabledState.STATE_DISABLED, vlans);

     

     

    iControl.CommonVLANFilterList[] vlanFilters = { vlanFilterList };

     

     

    m_snat.create(snats, snatAddresses, vlanFilters);