For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

willsweeper_131's avatar
willsweeper_131
Icon for Nimbostratus rankNimbostratus
Mar 04, 2014

Add an iRule to multiple virtual servers

I am looking for a script to add/apply an irule to a list of virtual servers, or virtual servers that contain "www" in the name.

 

Thanks.

 

19 Replies

  • Hmm, that's what I expected it to look like. Let's work through this iteratively then.

    tmsh list /ltm virtual |grep "ltm virtual"
    

    That should give you something like this:

    ltm virtual vip_oid.s2boss.corp.xxxxxxxxxxxxxxx.com {
    

    If you see several lines that look something like this, then add the AWK back in:

    tmsh list /ltm virtual |grep "ltm virtual" |awk -F" " '{ print $3 }'
    

    The idea here is that you're taking this returned line, splitting it on the empty space, and extracting the third element, which should be the VIP name. Give that a try.

  • I tried, but nothing was returned, just a blinking cursor on the next line. I then tried the same command on another ltm running version 11, got the output as expected.

     

  • Well that's just odd. I just spun up a v10 system and DID see results. Are you doing this from the Bash shell, or from within TMSH? What happens when you do this?

    tmsh list /ltm virtual |grep "ltm virtual"
    
  • I used putty to SSH to the LTM, then ran the command in there. The LTM is running version 10.2.4. I tried the above command, nothing returned. If I run it without "grep "ltm virtual"", then I got all the virutal servers. How did you run the command on yours?

     

  • So weird. This is just Linux Bash command line stuff. I tested with a 10.2.4 system as well, and using the Bash shell (not TMSH). What happens if you just grep a single word:

    tmsh list /ltm virtual |grep ltm
    
  • Hi!

    You COULD do some old fasioned stone age excel "magic" too. 🙂

    1. Select the virtual server list/table in the Web UI
    2. Copy it to Excel
    3. You get a column with only virtual server names, remove the other columns.
    4. Filter the VIP name column for www.

    Assuming that your VIP name column is A, input this in column B:

    ="tmsh modify /ltm virtual " & A1 & " rules { test-rule }"

    Autofill the B column and then you're done. 🙂

    /Patrik

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    I ran the following on a v11.3.0 box:

     tmsh list ltm virtual
    Display all 113 items? (y/n) y
    

    and then it displayed nothing. Using "/ltm" produced the same result. (Side question: What does "/" really mean here?)

    Is there a bug current for this?

    (The same command works in v10.2.4.)