Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
code share

Radware config translation

Problem this snippet solves:

This is a simple Python script that translates Radware text configuration file and outputs as config snippet and certificate files.

$ ./rad2f5
Usage: rad2f5 <filename> [partition]


./rad2f5 radwareconfig.txt MyPartition
Using partition /MyPartition/
IP routes:46
Non-floating IP interfaces:26
Floating IP interfaces:19
Virtual Servers:430
Certificates: 31
SSL profiles: 17
WARNING! Found L7 Regular Expression at "appdirector l7 farm-selection method-table setCreate l7Rule-Redirect"
Layer 7 rules:12
Layer 7 policies:4

!!  Copy all certificate files to BIG-IP /var/tmp and use load_certs.sh to load
#         Configuration
ltm policy /MyPartition/l7rule-Redirect {
    controls { forwarding }
    requires { http }
    rules {
            Redirect {
                    actions {
                            0 {
                                    pool SORRYPOOL

            ordinal 1
net route /MyPartition/ {
How to use this snippet:

This includes translation of routes and non-floating self-IPs, monitors, pools, virtual servers, certificates, SSL profiles and some layer 7 rules.

To install, either download the file attached here, extract and run it or use pip:

pip install rad2f5

To load the configuration to the f5 device, output to a file eg ./rad2f5 filename>newcfg.txt, remove the statistics header from the file with a text editor, upload the file into /var/tmp on the BIG-IP and test loading with tmsh load sys config merge file /var/tmp/<filename> verify. Fix any issues and load with tmsh load sys config merge file /var/tmp/<filename>

The script will also output the certificates and keys which should be uploaded to the BIG-IP /var/tmp directory and run file check_certs.sh and load_certs.sh to check and load the certs and keys.

Works with Python v2 and v3.

If you want something to be added then message me with details of the text and i will try to add it.

Feel free to add or change anything

Comments on this Snippet
Comment made 14-Mar-2018 by Shahid-CRIS 0

Traceback (most recent call last): File "rad2f5", line 555, in vars = splitvars(monitors[m]['text']) KeyError: 'text'

Comment made 14-Mar-2018 by Pete White

Thanks for the response Shahid-CRIS, I have fixed this - it was because of an uninitialized variable so it now creates the variable as an empty string if the text doesn't exist.

I have changed the file attached to the page so you can download and use that, or modify your own version as below: Line 157 or so:

if 'a' in opts:
    output['text'] = opts['a']
    # Added in v2
    output['text'] = ''
Comment made 14-Mar-2018 by Shahid-CRIS 0

Thanks it worked

Comment made 14-Mar-2018 by Pete White

Good! One point that i didn't make above is that the monitors are created but they are not assigned to the pools so you may want to do some manual assignment etc. This is because RadWare do monitor assignment to pool members and F5 generally do this at the pool level. I may look into fixing this.

If you have any issues with syntax etc then let me know and i'll amend it - I have only really used a couple of configs and the RadWare documentation is not very good about the CLI so if you have any configs that have issues or you want specific config included then PM me with the config and an explanation and i'll try to include it.

Comment made 20-Sep-2018 by William J Gonzalez 106


I am executing the script but i get this :

-bash: ./rad2f5-tmsh.pl: /usr/bin/perl"^M: bad interpreter: No such file or directory

Comment made 20-Sep-2018 by Pete White

Hi William, it looks like you have the wrong linefeeds in the file. Try looking through the script using vi and see if the lines have a ^M at the end. If so, transfer it to the platform using ASCII mode or copy/paste. Also, check that you have /usr/bin/perl as an interpreter for it to work. I built it on Cygwin.

Comment made 20-Sep-2018 by Pete White

Hi William, it has just dawned on me that I wrote this in Python, not in Perl! haha

I think you also have rad2f5-tmsh.pl, my code is just rad2f5.

Try running it with rad2f5 <filename> [<partition>]

Comment made 2 months ago by Avi 1

Hi Pete,

Thanks for this; major help !

I ran the script - on a mac - to test it and I ran into this error (btw. I changed the file name and added the .py extension)

 Traceback (most recent call last):
   File "./rad2f5.py", line 403, in <module>
     if vars[1] and vars[1].startswith('P='):
 IndexError: list index out of range

First I ran into this error

 File "./rad2f5.py", line 72
  print "Using partition " + partition
 SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Using partition " + partition)?

I'm using Python 3.6.5 :: Anaconda, Inc. - I had to change all the print statements to surround them with ( ). Prolley a python distro/version specific thing. After the change the script ran fine until the line 403 error.

Appreciate the help.

Cheers, Avi

Comment made 2 months ago by Pete White

Hi Avi,

There are two things here - one is about print and I can answer that now - I wrote this in Python v2.7 and i'm sure you know that print is one of the big differences between v2 and v3. I will look into this and change it to work correctly with v3.

On the failure point, I have a fair idea what the issue is - it's related to creating layer 7 rules and that part has quite a few options. Maybe you could PM me your config file and I will run it through and fix the issue.

Comment made 2 months ago by Avi 1

Hi Pete,

Thanks for the reply.

I'm not that deep into Python (yet) but I figured the print had something to do with different versions.

On the failure part - the source Radware config file had \ at the end of almost every line. I think it might have something to do with that. I got hinted by the monitor output of the script. So I'm editing the source config file to remove the backward slashes at the and and joining the config lines as one again.

Hopefully that will solve the issue for me. I'll let you know once the test file is done and ran the script against it - lot of config lines in there to be corrected :-(

Comment made 2 months ago by Pete White

If you can send me the original file, I can change the script to manage the \ line endings - it is best for it to be as useful as possible. Should be simple with regex.

Comment made 1 month ago by samuelovisua 0

Hi everybody, First of all, thanks Pete for sharing the script. I tried to execute but got the following error: --------- executed on windows 10 --------- Traceback (most recent call last): File "rad2f5_p3", line 426, in if rule in l7rules:

NameError: name 'rule' is not defined

I got the statistics output but nothing else, i mean, no config. Any clue whats happening? Thanks in advance! Br, Samuel.

Comment made 1 month ago by Pete White

Hi Sam,

I know exactly what that is - it is a typo by me. I should have put speech marks in and left them out there and also two lines above it. You can fix this yourself by changing:

if rule in l7rules:


if 'rule' in l7rules:

Do the same for if not 'name' in l7policies: a couplpe of lines above as well and that should fix it. I have been working on this script recently so feel free to download the latest version.

Comment made 1 month ago by samuelovisua 0

Hi Pete, Thanks again! I'll have a try! Br, Samuel