iControl 101 - #16 - SelfIPs

In this article, I will discuss the Networking.SelfIP interface in which you have control over the IP addresses owned by the BIG-IP system that you use to access the internal and external VLANs.

Initialization

This article uses PowerShell and the iControl Cmdlets for PowerShell as the client environment for querying the data.  The following setup will be required for the examples contained in this article.

PS C:\> add-pssnapin icontrolsnapin
PS C:\> initialize-f5.icontrol -HostName theboss -Username admin -Password admin
True
PS C:\> $SelfIP = (Get-F5.iControl).NetworkingSelfIP

Determining the list of configured Self IP Addresses

As is common in most interfaces, the Networking.SelfIP interface has a get_list() method that takes as input no parameters and returns a string list of all the defined SelfIP addresses.  On my system, I have two Self IP addresses: 10.10.10.1 and 20.20.20.1

PS C:\> $SelfIP.get_list()
10.10.10.1
20.20.20.1

Creating a Self IP

The create() method can be used to create a Self IP address.  The create() method takes as input a list of self_ip addresses, vlan_names, netmasks, unit_ids, and floating_states (for floating self-ip addresses across redundant systems).  If you specify STATE_DISABLED for the floating_state, you must use a unit_id value of 0.  If you are creating a floating address, you must use a unit_id of 1 or 2 and make sure that you have a fixed address on the same network as the floating address with the same netmask.

This example creates a fixed Self IP on the "internal2" vlan with an address of "30.30.30.1", a netmask of "255.255.255.0".

PS C:\> $SelfIP.create( (,"30.30.30.1"), (,"internal2"), (,"255.255.255.0"), (,0), (,"STATE_DISABLED") )
PS C:\> $SelfIP.get_list()
10.10.10.1
20.20.20.1
30.30.30.1

VLANs

You can get and set the vlan that a Self IP address is attached to with the get_vlan() and set_vlan() methods respectively.  The get_vlan() method takes as input a list of Self IP addresses and the set_vlan() method takes the same list but also a list of new VLAN names to use for each respective Self IP.  The following code with modify the VLAN for the previously created 30.30.30.1 Self IP to the "internal1" VLAN.  It will then query the value of the VLAN to verify that the method worked.

PS C:\> $SelfIP.set_vlan((,"30.30.30.1"), (,"internal1"))
PS C:\> $SelfIP.get_vlan((,"30.30.30.1"))
internal1

Netmasks

The netmask on the Self IP definition can be retrieved or modified with the get_netmask() and set_netmask() method.  Both methods take as input a list of Self IP addresses but the set_netmask() method has an additional parameter to pass in the new netmasks for the specified Self IPs.  This example will modify the netmask for the previously created 30.30.30.1 Self IP to 255.255.0.0 and query the value.  I will then change the value back to it's original 255.255.255.0.

PS C:\> $SelfIP.set_netmask((,"30.30.30.1"), (,"255.255.0.0"))
PS C:\> $SelfIP.get_netmask((,"30.30.30.1"))
255.255.0.0
PS C:\> $SelfIP.set_netmask((,"30.30.30.1"), (,"255.255.255.0"))
PS C:\> $SelfIP.get_netmask((,"30.30.30.1"))
255.255.255.0

Floating Self IP Addresses

If you are running a redundant setup and would like your Self IP address to float to the active unit, you can do so by creating a floating Self IP address.  This is accomplished by setting the floating_state to STATE_ENABLED and setting the unit_id to either 1 or 2 corresponding the the unit_id in your redundant setup that you would like to own the configuration for the address.  The following example will create a new floating Self IP address 30.30.30.2 on the internal1 vlan configured with a unit_id value of 1.

PS C:\> $SelfIP.create( (,"30.30.30.2"), (,"internal1"), (,"255.255.255.0"), (,1), (,"STATE_ENABLED") )
PS C:\> $SelfIP.get_list()
10.10.10.1
20.20.20.1
30.30.30.1
30.30.30.2

Unit IDs

You can get the unit id of a Self IP address with the get_unit_id() method that takes as input a list of Self IP addresses and returns the list of unit_ids for those values.  For floating Self IPs you can also call the set_unit_id() method to change the value to either 1 or 2.  This example changes the Unit Id value in the previously created 30.30.30.2 Self IP from 1 to 2 and then queries the value.

PS C:\> $SelfIP.set_unit_id((,"30.30.30.2"), (,2))
PS C:\> $SelfIP.get_unit_id((,"30.30.30.2"))
2

Toggling between Floating and Fixed

If you decided you no longer wish to have your Self IP be floating, you can change it to fixed by calling the set_floating_state() method which takes as input a list of self ips, and a list of ENABLED_STATE enum values.  In this example I'm disabling the floating state by passing in STATE_DISABLED.  You'll notice that the unit_id has changed from 2 to 0.  I followed that up by turning it back into a floating Self IP by passing in STATE_ENABLED.  In this case, you'll see that the unit_id was set to 1 as the default.  If you want it back to the value of 2 as was set above, you will have to call the set_unit_id() method again specifying a value of 2 for the unit_id.

PS C:\> $SelfIP.set_floating_state((,"30.30.30.2"), (,"STATE_DISABLED"))
PS C:\> $SelfIP.get_unit_id((,"30.30.30.2"))
0

PS C:\> $SelfIP.set_floating_state((,"30.30.30.2"), (,"STATE_ENABLED"))
PS C:\> $SelfIP.get_unit_id((,"30.30.30.2"))
1

Deleting Self IPs

If your Self IP not longer has any use to you and you would like to get rid of it for good, then the delete_self_ip() method is what you want,  Just pass in a list of Self IP addresses and it will wipe them out.

PS C:\> $SelfIP.delete_self_ip(("30.30.30.1", "30.30.30.2"))
PS C:\> $SelfIP.get_list()
10.10.10.1
20.20.20.1

Oh, and for those who like to live on the edge, there is also a delete_all_self_ips() method that takes no input and deletes all defined Self IPs on the system.  Use this method wisely...

Conclusion

By knowing how to use the methods in the Networking.SelfIP interface, you now have all the tools to automate the creation, management, and deletion of Self IP addresses on your BIG-IP.

 

Published Jun 05, 2008
Version 1.0

Was this article helpful?