Kemp Support, how can we help?

The latest application delivery knowledge and expertise at your fingertips.

Creating Virtual Services via a Linux Bash script using RESTful API.

A Bash script can be used to create multiple Virtual Services quickly via the RESTful API from a Linux host.

In this example, the Bash script will be used to create multiple Virtual Services - each with a different Virtual IP address but with the same Real Servers.

 Step 1. Create an IP Address List File

In this example a file called iplist is created. This contains a list of the Virtual IP addresses that will be used. 

2. Create a Script to Add the Required Virtual Services

The following script will create a new Virtual Service for every IP address in the IP list file with properties as can be seen in the RESTfulAPI command. These properties can be changed to suit requirements. Please refer to the RESTFul API Guide for available parameters.

In this example the IP address of the Loadmaster is and password for the bal user is PASSWORD. This should be changed to suit the relevant setup.

Note: To enable the Virtual Services on creation, refer to Step 6 for the additional text to add.


The example script text is below:

#! /bin/bash for IP in `cat iplist`
wget "https://bal:PASSWORD@$IP&port=80&prot=tcp&AddVia=0&ForceL7=Y&CheckType=http&$IP&StartTLSMode=0" --no-check-certificate

wget "https://bal:PASSWORD@$IP&port=80&prot=tcp&rs=" --no-check-certificate

wget "https://bal:PASSWORD@$IP&port=80&prot=tcp&rs=" --no-check-certificate


3. Make the File Executable

Change the permission of the script file to make it executable by running the chmod command:

4. Enable the API Interface on the LoadMaster

In the main menu of the LoadMaster Web User Interface (WUI), go to System Configuration > Miscellaneous Options > Remote Access.

Select the Enable API Interface check box.


5. Run Script

 Execute the script by running the following command:


The Virtual Services are now created on the LoadMaster containing the appropriate Real Servers.


6. Enabling the Virtual Services

Depending on the situation, you may want to enable the Virtual Services when creating them. This can be done by inserting a line with the following syntax to the script before the done line. The Virtual Service being enabled is referenced by the IP address, port and protocol. So, following the syntax of the script above:

wget "https://bal:PASSWORD@$IP&port=80&prot=tcp&Enable=Y"  --no-check-certificate

Alternatively, if you would like to do this separately you can create another script, for example, and run it as a separate script.


Example script to enable the Virtual Service:

#! /bin/bash

for IP in `cat iplist`

wget "https://bal:PASSWORD@$IP&port=80&prot=tcp&Enable=Y"  --no-check-certificate



Please refer to the following article in order to Enable RESTful API Interface.

For further details on the RESTful API, including details about the commands and parameters available, please refer to the RESTful API, Interface Description document.

Was this article helpful?
0 out of 1 found this helpful