Skip to content
CBT Nuggets
DemoBook a Demo

Working With iRules

This skill covers the fundamentals and advanced uses of F5 iRules, an event-driven scripting language used for managing and manipulating network traffic. Key topics include understanding iRules syntax and structure, configuring traffic steering and redirection, logging events for troubleshooting, and handling errors effectively. The skill also emphasizes the importance of familiarizing oneself with common iRules commands and events, especially for those preparing for the F5 LTM Specialist certification exam.

Full skill from F5 BIG-IP. Preview the IT training 23,000+ organizations trust.

47m

Skill 6 of 12 in F5 BIG-IP

Introduction

So you want a tool that you can use to do things like redirect requests, manipulate data, or even send specific inbound connections to a specific member server in a pool? You've come to the right place because iRules can do all of those things and much, much more. We're going to explore iRules and some of their more common uses. We'll create some iRules and see them in action and discuss the importance of being able to read an iRule and know what its purpose is.

iRule Events and Commands

When it comes to iRules, they have their own set of rules as far as what triggers them, the actions they take, and their formatting. Let's jump in and talk about all of these iRules rules.

Knowledge Check

iRules are __________ driven. (What word best fills in the blank?)

iRule Commands

Now that we understand the makeup of iRules and that they are event driven, it's time to take a look at our command options which are many.

---> F5 iRule command documentation

Knowledge Check

There is a very simple list of iRule commands, about 20 commands in all.

iRule Logging

One of the features we can do with iRules is to log data. We can decide when a specific event occurs that we should log specific data. This can be very helpful for not only record of the event, but for troubleshooting.

Knowledge Check

To which file location does the following iRule send its log data? CMD: log local0.notice "Host: [HTTP::host], Client IP: [IP::client_addr]"

iRule Errors

What? iRules can have errors? Absolutely, since iRule is basically a script it can definitely have errors occur. That being said, how do we troubleshoot errors and where are these errors logged to?

---> F5 iRule error example

Knowledge Check

To where are iRule errors logged?

iRule Traffic Steering

Another popular use of iRules is to "steer" traffic. We may want to redirect traffic to another location, or send traffic from a specific source to a certain pool member. Let's take a look at how we can do this.

Knowledge Check

If we want to send an incoming web request to a different location, which of the following EVENTS would we use to trigger the iRule?

Validation

It's time to answer a few review questions dealing with iRules. After the questions will be a solution video where I'll walk through the questions and explain the answers.

NOTE: If you plan to take the F5 LTM Specialist exam you will want to spend some time on the F5 DevCentral site looking at various iRules and learning what they do. This will allow you to become familiar with many of the more common events and commands used in iRules.

Question 1:

Knowledge Check

Your company is rolling out an updated web application at a new URL. The old URL is www.nuggetlabz.net and the new URL is www.nuggetlabz.com . Which of the following iRules will allow clients connecting to the old URL to still be able to access the new updated web application? Refer to the images below and choose the answer that correlates to the correct image.

A.
when HTTP_REQUEST {
if {[HTTP::host] equals "www.nuggetlabz.com" }
{
HTTP::redirect "http://www.nuggetlabz.net" } 
}

B.
when HTTP_DATA {
if {[HTTP::host] equals "www.nuggetlabz.*" }
{
HTTP::redirect "http://www.nuggetlabz.net" } 
}

C.
when HTTP_REQUEST {
if {[HTTP::host] equals "www.nuggetlabz.*" }
{
HTTP::redirect "http://www.nuggetlabz.com" } 
}

D.
when HTTP_REQUEST {
if {[HTTP::host] equals "www.nuggetlabz.net" }
{
HTTP::redirect "http://www.nuggetlabz.com" } 
}

Question 2:

Knowledge Check

Your company has recently moved its web application to a new location and to ensure users can still access it at its old location you've setup a redirect on the application servers. You've been tasked with setting up an iRule that will log all of the redirects so that you can ensure it's working properly. Which of the following iRules will do this? Refer to the images below and choose the answer that correlates to the correct image.

A.
when HTTP_RESPONSE { 
  if { [HTTP::is_3xx] }
 {
  log local0. "redirecting client ip address   [IP::addr [IP::remote_addr]]" }
}

B.
when HTTP_REQUEST {
  if { [HTTP::is_301] }
 {
  log local0. "redirecting client ip address [IP::addr [IP::remote_addr]]"} 
}

C.
when HTTP_REQUEST { 
  if { [HTTP::is_redirect] } 
  {
  log local0. "redirecting client ip address [IP::addr [IP::remote_addr]]" }
}

D.
when HTTP_RESPONSE {
  if { [HTTP::is_redirect] }
   {
  log local0. "redirecting client ip address   [IP::addr [IP::remote_addr]]"}
}

Question 3:

Knowledge Check

When an error occurs within an iRule in production, what will the end result of the connection be?

Question 4:

Knowledge Check

If your iRule isn't working as expected, what would you look for in the /var/log/ltm log file that would indicate an iRule error?

Validation question solution video:

Knowledge Check

Have you used iRules on a Big-IP device?

This interactive assessment is available in the full learning experience.

Want to answer questions like this yourself?
with no purchase required. Already have an account?

View Transcript

iRule Events and Commands

0:00Let's talk about eye rules.

0:02So we're starting off here with some lower level eye rule

0:06discussion.

0:07Just as a quick refresher, in case you need it,

0:10that eye rules are an event driven language.

0:15And what does that mean?

0:15Well, it means an event triggers a command

0:19or triggers something to happen.

0:20So what does an event?

0:22Well, it could be things like when a connection

0:25is established from a client to a server,

0:28or it could be the response from the server to the clients.

0:33Or during this here, we have the F5 here, or our big IP.

0:39Well, when the big IP chooses where to load balance something

0:43to, that's an event, there's lots of different events.

0:48And actually, when this client connects in,

0:51remember, we're going to have that TCP three way handshake,

0:55most likely, that's going to terminate here at the big IPs

0:59external, or the IP of the virtual server.

1:02And that connection, when it's established, that's an event.

1:06So whenever there's an event, then we

1:09can trigger some commands to run.

1:13And that's how we do that.

1:15So it's really like a win.

1:17An event is win.

1:18Win this happens.

1:22Then we want to do this.

1:25And that's pretty much how I rules work.

1:27So let's take a look at an example of an I rule, or two.

1:32All right, here we go.

1:33Here's a couple of examples.

1:34So when here we have the client accepted,

1:39so that is the client accepted the connection.

1:42And here we're actually doing an if in here.

1:45So if the IP of the client address

1:49equals 172.16101.5, then drop that connection.

1:54Oh, that's pretty interesting.

1:55So here's another one.

1:56Win the HTTP request.

1:59So here we're looking at HTTP data.

2:01So really, we should be using our HTTP profile

2:06to give us access to layer seven data, where that HTTP request

2:10will reside so we can read what's in it.

2:13So it says here, win the HTTP request,

2:17it wants you to go ahead and log local zero.

2:21That's our var log LTM.

2:24It wants you to log host.

2:25And then what this is, is a variable.

2:27It's information in there actually.

2:30So it's pulling out of the HTTP request, the host.

2:34And it's going to grab the client IP address there.

2:36So basically every time there's an HTTP request,

2:39it's going to log the host and client IP address.

2:43So this is what it is.

2:45So we have our event here.

2:48And this one is--

2:50there we go, let's make-- there we go.

2:52Our event is client accepted.

2:53This one is HTTP request.

2:56And then we're going to have a command after that.

2:57You can do an if statement or if else.

3:01Or you could simply run a command to do something

3:02like log something for you.

3:05So there you go.

3:06Now, I do want to talk about something else here.

3:08And this is iRulePriority.

3:11And that's because our iRuless are, well, in priority.

3:14If you have a list of rules here,

3:16well, how does this work?

3:18Which one goes first?

3:20Comes down to priority.

3:21And you can assign a priority value to an iRule.

3:25And if you do not assign one, the default priority value

3:32is equal to 500.

3:35And the way this works, though, is the lower the number,

3:40the higher that priority.

3:41So 0 through, let's say, 500.

3:45So if I have a list here and I have some at 0 and maybe 1

3:49at 10 and 20 and 100, well, the priority is from 0

3:54to higher numbers.

3:56Now, if you do not assign the value,

3:58it uses the default value of 500.

4:00And let's say in your web UI here,

4:02our config utility, everything set to 500.

4:05At that point, it is top down.

4:07So it will just go top down from what you see in your view.

4:11And it'll go through until it makes a match.

4:14So that's the basics of events and commands and priorities

4:18with iRoles.

4:19Now, what do you say we jump in in the next digit

4:22and start taking a look at iRole commands?

4:24Because there are a few of them, as you will find out.

4:28So I'll see you there shortly.

4:30[BLANK_AUDIO]

iRule Commands

0:00All right, as I said, we're going to now take a look at some I rule commands

0:05because we've talked about events

0:06And we're gonna look at events as well. We're gonna look at both of them

0:08So here we are. We are at the F5 documentation. I rules home. This is where we

0:13come for our I rule references

0:16And I will provide this link here in the nugget. So here we go

0:20Wow, let's get started

0:23Because you'll see there's lots of commands now. Let's take a look over here at

0:26the left

0:27See if I can't here zoom in a little bit now here on the left I rules home. So

0:32first of all

0:32We have big IP commands and events by version. So let's click on that. Let's

0:37take a look at this

0:37So what we have is for each version you're gonna be able to go in and look at

0:42what changes were made for that version

0:44Which is good because as you upgrade versions throughout the life cycle of your

0:48big IP

0:49You're gonna need to understand if you're using I rules

0:52What I rules have changed. So let's say let's take a look at the 17 1 0 is the

0:57latest there

0:58And we'll see there's just three of them here dealing with the ASM module

1:03So we have this new command. It looks like is authenticated login status and

1:08username

1:09So we can actually use those this username is request username from a login

1:12attempt through a login session

1:14So that we can maybe log that or do something it would if if we need to but you

1:19'll see here

1:20This is a couple of commands and these are just the changes though. Keep that

1:24in mind. These are only the changes

1:25so let's go back here and

1:27Let's go back over to our menu on the left here

1:31Now here's what I want you to see all of these will click on global contain a

1:37command list and we're gonna scroll all the way

1:40Yeah, lots of commands, right and they're associated events. So these events

1:45can be used to trigger these commands

1:48so here events these are global commands and events and

1:52So server initialization

1:56We have persist down name resolved a lot of them here, right?

2:00Okay, so let's go look at some commands then so these are some commands up here

2:05. So as you can see there's a lot of them

2:07I know a lot right

2:09So as we keep going there you go. So those are our global

2:15But we also if we scroll down here, we see this keeps going. Yeah a whole lot

2:20down here. There we go all the way down

2:22to

2:25At the bottom our X and now

2:27So when we start working with maybe the TMM we go take a look at the TMM. Well,

2:32there's some TMM commands

2:33There are no events associated with that, but you can use other events to call

2:39or trigger

2:39the command to run

2:42Maybe we've got triple a for authentication and

2:46Authorization to access you got here's some access commands. There's APM

2:51commands ASM

2:53Let's see. There's just a whole bunch really so when it comes to these I rules

2:58That's when we're looking to do something with the incoming data

3:01We're looking to manipulate the data or steer it to a specific

3:05Destination maybe do a redirection or send it to a specific pool member

3:09We can again manipulate the data in it. We can change information

3:12Here's some HTTP

3:14This is something you should definitely look at if you plan on taking the

3:17certification for the LTM specialist

3:20You will be tested on

3:22The I-rolls and you're gonna need to take a look at an I-roll and figure out

3:25what it's doing. So HTTP

3:28It's good to know because we're gonna actually look at some of these especially

3:32when it comes to

3:32Response and request because here at the request for example if I click on this

3:38it's gonna take me in here

3:39And I can see this HTTP request we return to the raw HTTP request headers as a

3:43string

3:44So that you can actually access that information in the HTTP header and the

3:50request is gonna contain the information being requested

3:53Such as URI this being requested the URL the target name or watch it not

3:59The destination address all that stuff. That's your HTTP request

4:04But then also we have a HTTP response and the response is gonna be return

4:09traffic

4:09From the server and that's gonna contain information such as if there's red

4:14irection is going on it's gonna be in the response

4:17You'll see that coming up. So again as we go back. There's a whole lot of these

4:23So again if you plan on taking the certification exam

4:26I highly recommend you go over to Dev Central and you start looking at I-roll

4:30just to search for I-roll

4:31That's all you got to do and you will find tons of articles and

4:34People working on I-roll so that you can get familiar with many of the most

4:39common commands

4:40So that you'll be able to decipher what I-rolls are used for okay?

4:45That's very helpful if you're gonna take this certification exam now if you're

4:50not this is where you come and this is your

4:52repository for looking for information and and to be honest we're probably just

4:57gonna Google for I-rolls but this is the

5:00Indol BL to your resource for these commands so you can always go and take a

5:05look at a command

5:06So let's say you you see one that says HTTP header

5:09Well, what does that mean so you click on here and it's gonna tell you what it

5:13means?

5:13Okay, so what it's used for the syntax that you can use it for some additional

5:19information down here

5:20That's gonna help you with your I-roll so this is such an important place

5:24When it comes to your I-rolls and the commands and the events associated with

5:30them

5:30So this should be bookmarked in your studies when it comes to your

5:34LTM specialist command and really if you're an LTM administrator or big IP

5:39administrator

5:40This you need to be bookmarked somewhere

5:42This is what you're gonna be using when it comes to your I-rolls it's gonna be

5:45a great resource for you

5:47And now you know where it's at and the link will be right below the video

5:51Or you can see it maybe up here in the video. We're not quite sure how this is

5:55gonna turn out as far as zooming

5:56So there you go. That is your I-roll event and command

6:01resources straight from F5 in the next night. We're gonna talk about I-roll

6:07logging. So see you there shortly

6:09[BLANK_AUDIO]

iRule Logging

0:00Alright, here we are in our iRULES home once again as we saw in our last nugget

0:06.

0:06And now we're taking a look at iRULOGGING.

0:08Okay, and this is when we use a command to log information as part of an iRUL

0:14so that

0:14an event occurs and as a result of that event we trigger a command to log some

0:20data.

0:21And this is used very frequently, like a lot.

0:24And especially the troubleshoot.

0:26Because if I'm working on something and I need to gain access to specific

0:30information,

0:32let's say I'm trying to find out where something is load balanced to.

0:35Well what I can do is actually use an iRUL to identify my test box coming in

0:41and then log

0:42where it's been load balanced to.

0:45So I can use it to troubleshoot.

0:47There's lots of things.

0:48We use them a lot for troubleshooting, especially with the login command.

0:51Okay.

0:52So that being said, let's go over to global.

0:54There we go.

0:55And log command.

0:56So let's scroll on down here and there it is.

1:00Log right here.

1:01Let me zoom in.

1:02Right there is our log command that says generate and logged a message to the

1:05syslogging utility.

1:07Awesome.

1:09So let's go ahead and click on that.

1:10Let's find out some information about it.

1:13Alright, super.

1:14So this generates and logs specified messages to the syslogging utility which

1:20we just saw.

1:21Alright.

1:22Let's take a look at the syntax log or you could simply put a message in there.

1:27You can also use log with the no name option.

1:30The no name option.

1:31What this does, it prevents the logging of the iRUL name and the event that

1:36prefix the

1:36actual message.

1:37Alright, it just abbreviates your log entry.

1:41We can also set the facility level in this facilities where it's going to log

1:45to member

1:45our local zero is our var log LTM.

1:48Let me have our logging level, remember that's zero through seven or we can use

1:52the words

1:52and we can then add a message after that.

1:56Okay.

1:57But if we want to log to a remote host, let's say to a, I don't know, syslog

2:01server, then

2:02you can put in here the remote IP address and remote port where you want to log

2:08to.

2:09So it'll send it to that destination instead of your local facility.

2:13Okay.

2:14So if we go down here and look at some examples.

2:17Here we go.

2:18So as simple as it gets log local zero, you know, this message and these are

2:24variable

2:25to have dollar signs in front of them.

2:26There's a system variables that can be used.

2:30Alright.

2:31So let's see.

2:32Here you go.

2:33Here's triggering it when client accepted.

2:35So when a client accession is accepted, what we can do is log and this is

2:40logging to,

2:41that's right, a remote syslog server.

2:44We're also providing information here.

2:47Alright.

2:48We've got our local zero and our info level and we say here client connected IP

2:53and then

2:53we're going to have the IP of the client address.

2:57So those are a couple of examples.

3:00They're dealing with the log.

3:02So now that we see what this looks like, let's go ahead and see it in action.

3:07Alright.

3:08Here we go.

3:09Let's go over here.

3:11We're on our big IP and what we're going to do is go over here to local traffic

3:17, go

3:17down to our iRULES and I've got one right here called Bob logging.

3:22Let's open this up and see what this looks like.

3:24Alright.

3:25It says when HTTP requests, so a web request, whenever a web request comes in,

3:30it's going

3:31to log local zero.

3:32Alright.

3:33That is our var log LTM.

3:35I'm going to log it as a notice level.

3:39It's going to provide host, the HTTP host and then the client IP and here the

3:45client

3:45IP address.

3:46Now, it's very important we understand the formatting use here.

3:49So you have an event and that event triggers a command.

3:53The command needs to be wrapped with, that's right, these curly brackets and

3:58then down

3:59here whenever we're trying to pull information from like here our HTTP headers,

4:04those need

4:05to be hard bracketed.

4:06Okay.

4:07And you'll see it over here as well from IP, we're pulling that information in.

4:11So really this is just going to log some information for us.

4:13So let's turn this on.

4:15So this is my Bob logging.

4:16Let's go over here to virtual servers.

4:18Let's go over here to my HTTP app one, let that load up, go over to our

4:22resources and

4:23under our iRULES right here we're going to add scroll over here to manage.

4:28There we go.

4:29We're going to add Bob logging because an iRUL not attached to a virtual server

4:33is simply

4:34a stump on a log.

4:36Finished.

4:37There you go.

4:38Now this is actually going to be used.

4:40Alright now let's go ahead and see this in action.

4:43So what I'm going to do is let's see the spring up our terminal and actually we

4:49're going

4:49to go jump to our windows box first.

4:51There we go, windows box.

4:53So I'm going to open this up and I'm going to query.

4:55There we go.

4:56Let's do a incognito window just in case we have some cached information.

5:00There we go.

5:01Alright.

5:02So that's that.

5:03And let's bring this up.

5:05And let's do var log LTM, tail it.

5:11And there we go.

5:12Right here.

5:13There is our information.

5:15So this is big IP one.

5:17If I buy up notice and here's the rule that it hit says, it's our Bob blogging

5:23rule HTTP

5:24request.

5:25There's the host.

5:261.2.16.101.11.

5:27It's a big IP and the client IP 1.6.2.16.101.5.

5:30So now we see that logging in action.

5:33We're at IDR and cool.

5:35Alright.

5:36Now here's a question.

5:37Why would you ever want to use this?

5:38Well, we might use this to log specific traffic of activity that we want to

5:42document in the

5:43logs.

5:44Maybe we want to document when certain IP addresses or networks communicate and

5:49we might want

5:50to see that.

5:51We might want to graph that.

5:52So we send it off to a syslog server from here.

5:55And on that syslog server, we may have some applications that can use that sys

5:58log information

5:59to graph and show where things are coming from, so on and so forth.

6:03But then again, we could use it for lots of things logging, especially with

6:06troubleshooting.

6:07If I'm having problems with something, I can come in here and I can go back to

6:12my, let's

6:13see over here to the big IP and come down to the eye rules and say, maybe I

6:17want you

6:18to instead of log this information, I want you to log additional information,

6:22right?

6:22I can pull lots of stuff.

6:24And it's not just HTTP requests.

6:25I can do HTTP connect or HTTP response or lots of different things or well, we

6:31saw all

6:32the commands we can use.

6:33So when something happens, we can actually log all this information.

6:37And that way it'll help us troubleshoot.

6:39See what's going on underneath the hood, if you will, of our system house

6:43processing

6:44that data.

6:45Now do keep in mind that when we're doing this, if we're sending a bunch of

6:48stuff like this,

6:50every HP connection to the logs, that's going to create a lot of log data.

6:55And our logs are going to overwrite quite frequently.

6:57So this is not something I would do in production necessarily, unless I had a

7:03really good reason,

7:05because every time there's an HTTP request, it's going to log where it's coming

7:09from and

7:09where it's going to here.

7:11And that's just a whole lot.

7:13And actually, let's take a look at creating this because this I just showed it

7:16to you,

7:16right?

7:17So what you can do is we're going to win a speed underscore and you'll see it

7:21fills in.

7:21It shows you all your events that you can use at this point.

7:25So it could be response, request, send, release data request.

7:29And so we'll just go with our request local, like we did.

7:32And we do our open curly bracket and then tab that out.

7:36And you don't have to.

7:37It just makes it easier to remember.

7:38I say I want to do log, right?

7:40So you hit L.

7:41Well, what do you want to do?

7:42These are all your commands that start with L up here.

7:45So I'm wanting to do listen, or we're just going to do log.

7:49And there I want to do, there we go, local and it says, well, where to local

7:54address

7:55or let's just local zero and you put your period in there.

7:58And then what level are you going to do?

8:00We put our notice, yep, in for notice, there you go.

8:03And then we're going to put our message.

8:04So here, if I want to do, let's say host and I put the colon because that's

8:09just the

8:10word host shows up there.

8:12And then what do I want to follow that?

8:14Well, that's where my hard brackets are going, not curly brackets, but your

8:18straight brackets.

8:19And I want HTTP data.

8:21So here, put that now, what do I want?

8:23It gives us all this very nice IDE or integrated developers environment kind of

8:29in this to

8:30help us along with our options because there are a ton of options.

8:35So what we could do is what do we want here?

8:38The host, do we want the host, how about IP address?

8:40Is IP address in here or address is probably in here?

8:43And let's see, see, to say we'll follow up header host, host, we looked at

8:48method,

8:48pass through pass payload query redirect.

8:50And I don't see any kind of address, which is fine.

8:54But you could do the something like the URI, we could actually find out what

8:57you are either

8:58going to try to access.

8:59So here, we can do that.

9:01So actually here, we would probably change this to URI because it's going to

9:05kind of match

9:06that you could do that.

9:07And then put our comma, what we want to do, our client and IP and these are

9:12just words

9:12at this point.

9:13But then once I bracket, I'm putting something important.

9:16I want to pull information from the IP header.

9:19So I could say IP and there's client address.

9:22So I could do client address that we did.

9:23We could do address is better to do client address because the address you're

9:26not sure

9:27if you're going to get like a destination or source.

9:30Client address is very specific.

9:33I could do remote address, server address.

9:35Let me see what I'm going with that there.

9:37So let's actually go with let's just leave client address.

9:40But then what if we wanted to know the port number?

9:42Well, then we could put comma port colon space and again, those are just words

9:47here.

9:48Now if we go to TCP, that's where our ports are going to be because it's the

9:52TCP layer.

9:53Let's see if we go down here and find.

9:56Let's see, there's payload, push, receive, scale and there's unused port.

10:04Let's see, server port.

10:06There's server port you could put in there is there and that's probably that's

10:09going

10:10to be like destination port.

10:11That's what we'd be looking for is our client port.

10:13There probably is.

10:14Yep, there's our client port.

10:15So really we'd be looking probably at our server port.

10:18We want to know where it's going to on the port.

10:20So at that point we'd close that.

10:22All right, and we close this and then we have to wrap up with a curly bracket

10:27to finish

10:28it out and it just like that nice little formatting.

10:31There you go.

10:32Or if you're going to do more than one thing, we could then close that.

10:35But then what we could do is actually we'd probably do this.

10:40Go back here.

10:41I'm going to close that curly bracket and I'm going to do an open bracket,

10:45enter and

10:45then I could run another command if I wanted to.

10:48So I could do lots of different.

10:50I mean just I don't know.

10:51The sky is the limit when it comes to these commands because there's so many of

10:54them.

10:55But you could put your next command down here and then we'd come down here and

10:59go ahead

11:00and close that out.

11:01So then you could run and you could nest all these commands and you can do if

11:04ill statements,

11:05you know, lots of different things as you get in here and start playing with

11:08these.

11:09And then I think too, you can hover over this like HTTP request and it's going

11:12to give

11:13you some information you can look at.

11:15So oh, well look, there's some examples.

11:17HP redirect.

11:18Where's this being sent to?

11:20You know, all these wonderful things.

11:22And actually we're going to deal with working with steering, which is where we

11:27steer our

11:27traffic to a new destination or somewhere else.

11:30And we're going to look at that here upcoming shortly.

11:33So that wraps up our I rule logging.

11:38We're going to actually look at I rule errors because believe it or not, you're

11:41going to

11:41see a bunch of errors when you go playing with these things.

11:43They can be a serious pain in the rear at times, but use your documentation, do

11:48some

11:48Googling and research and look for the errors.

11:50Those are going to be key.

11:52All right.

11:53So there we go.

11:54That wraps this up.

11:55I'll see you in the next nugget.

11:55[BLANK_AUDIO]

iRule Errors

0:00It's time to talk about errors.

0:02I-rule errors to be more specific.

0:05And when it comes to I-rule errors, well, guess what?

0:08You will encounter them if you work with I-rules.

0:11So that's when you have an I-rule

0:13and you have the correct nomenclature

0:15and such in there, your events and commands,

0:17but when it's being processed, generates an error.

0:22All right, and these are known as TCL errors,

0:25or tickle errors, because tickle,

0:27which is tool command language,

0:28is the language that I-rules use

0:31that you see when we're creating I-rules, right?

0:33Those are called the tickle language, or TCL.

0:37Now, these errors are invaluable

0:41to troubleshooting your I-rules

0:45when you're having problems with them.

0:47Now, these are logged to our local zero,

0:50which is var log LTM.

0:51Let's take a look real quick here.

0:53So this is pretty much what you're gonna see.

0:55Something like this, and you're gonna have a reason.

0:57It could be that you can't read something,

1:00or the variable doesn't exist.

1:02It could be lots of different things.

1:03And again, they're located in the var log LTM file.

1:06I'll provide a link to this article here below the video.

1:10Now, I do wanna point out that if an error occurs

1:14within an I-row while it's being processed,

1:16the connection is going to most likely be reset.

1:21So that user's connection will be reset,

1:24and there you go.

1:25That's kind of what's gonna happen

1:26when you have that, and that'll be an indicator

1:29that you have a problem with an I-row.

1:31Use your descriptions, impact, and recommended actions.

1:34I recommend an action to figure out what's going on.

1:37How about that?

1:38(laughs)

1:39Pretty straightforward.

1:40All right, let's go in here.

1:41I was able to generate some errors.

1:42It's not that hard.

1:44So what we're gonna do is,

1:46I wanna show you real quick something real quick.

1:48Let's do a LS-L.

1:52I'm not gonna do that.

1:54We'll do var log LTM.

1:55I would just var log really.

1:57Either our log files.

1:58I wanna show you this because what happens with these,

2:01where's my var log LTM, where's my LTM?

2:04There, there, LTM's.

2:05Okay, so your most current logs are kept here in LTM,

2:10but once they're overwritten,

2:11once they get to a certain size,

2:12they're shipped off to LTM.1.

2:15And down to .2, but once you get down to .2,

2:19they're being zipped, okay, compressed.

2:21So what I'm gonna look at is LTM.1

2:24because I don't have any errors

2:26in my LTM most recent log,

2:29but I do in my LTM.1 log.

2:30And it happens with all these.

2:32That's the way logging works in Linux, okay?

2:34So let's go ahead and do this.

2:36Let's enter, let's clear the screen here.

2:38Let's see the App Arrow a couple times, and there it is.

2:41What I'm gonna look at,

2:42what I'm doing is,

2:43I'm gonna, I'm reading the var log LTM.1 file,

2:46and I'm searching for TCL, but hit enter.

2:49These are TCL errors that we see here.

2:51So if we look at that, we get some information,

2:54like a timestamp where it's happening, the error,

2:57you get an ID number here,

3:00and then we see TCL error,

3:02and it is in the Bob validation I rule, all right?

3:07And it says that the server connected,

3:09this is bad IP network address format in line one.

3:13And this is what the errors look like,

3:16and this is where they are located.

3:18So it's very important for you to remember,

3:20we're looking for tickle errors, TCL errors,

3:24and these are associated with our I-RULs,

3:26and they are maintained in, that's right, var log LTM.

3:31It's very important we remember this.

3:32This is invaluable to troubleshooting our I-RULs

3:35when we're having problems with them.

3:37So that's how we can go ahead and look for I-RUL errors

3:41or tickle errors within the big IIP.

3:44Next up, we're gonna create some I-RULs

3:47and work with traffic steering.

3:49That means we're going to manipulate traffic flow with I-RULs.

3:52So I'll see you there shortly.

3:53[BLANK_AUDIO]

iRule Traffic Steering

0:00It's time to work on traffic steering or traffic manipulation with iRULES.

0:05Now I've got a couple of iRULES here we're gonna look at.

0:07We've got two of them in particular.

0:08One is Bob redirect.

0:10There is Bob redirect URI.

0:12Now the first one, well actually let's just go ahead and look at them okay.

0:17And here's what we're gonna do.

0:18I'm going to click in here.

0:20This is the, let me zoom in just a little bit, there you go.

0:25This is the iRUL.

0:28Obviously, now I'm gonna pause the video here.

0:31Actually I just encourage you to pause the video here and figure out what this

0:37iRUL is

0:37supposed to do okay.

0:40And so go ahead and pause this and take a look and when you're ready go ahead

0:44and resume.

0:47Alright I'm guessing you figured it out hopefully.

0:51Alright let's talk about this.

0:52So this starts off with the event when an HTTP request is received okay.

0:58Again it's looking at if the IP address is equals 172.16.101.5.

1:06Oh what is that?

1:07What's percent one?

1:08Think back to your partitions remember our administrative partitions?

1:12That tells it that this IP address belongs to the partition one.

1:17Without that you might run into errors or if you have IPs and different

1:20partitions you

1:20will want to define the partition there.

1:23Keep that in mind.

1:24So what this is, this is just text here.

1:26It says if this IP address and this IP address is actually going to take this

1:33information

1:34is what we're saying.

1:36If the client IP address equals 172.16.101.5 which is my Windows test box then

1:42go ahead

1:43and log a notice log local zero that's our var log LTM.

1:48Log that notice and use host it's gonna give me my HTTP host which is gonna be

1:53the big

1:53IPs IP address.

1:55On IP IP address of the client 172.16.101.5 and redirected.

2:01So basically it's gonna say hey I saw an HTTP request from 172.16.101.5 and I

2:08redirected

2:08it and that's what we're telling it to do here.

2:10Not redirected but we're saying just log that it was redirected.

2:14So basically it mats and it's processing the rule.

2:17Now the next we're defining a pool.

2:19So use a keyword pool and define the pool that I want it to redirect to then I

2:24actually

2:25defined the member of the pool that I want to redirect to which is 1011.03 on

2:31port 80

2:32and now pay special attention.

2:34We're looking at these brackets.

2:36They're very important.

2:37See this gets wrapped right in here.

2:41That's the one command.

2:43This is the next command of brackets.

2:48And this is the next command.

2:49And all these commands are wrapped with this bracket and this bracket.

2:53And then whenever we're pulling IP address information or any information from

2:59the big

3:00IP like the IP client address we're going to have those squared brackets.

3:05You see we're saying here, same here.

3:08We're pulling those in squared brackets.

3:10Alright so that's what that is supposed to do.

3:14What do you say we tested out shall we?

3:16So this is the Bob redirect iRule.

3:19So let's go to virtual servers.

3:20Let's go to our HTTP app.

3:23One virtual server resources.

3:27Under my iRule.

3:28I'm going to remove that logging.

3:29I don't want to be confused because I don't want to log this and the other.

3:33There we go.

3:34So now let's go scrolling up here.

3:39Bob redirect add.

3:41Thank you and finished.

3:44Alright now that is there.

3:45So let's go back to the iRule.

3:47Quick I will list Bob redirect.

3:50This is what we want to happen.

3:52So I should be sent when I'm on my Windows test box here.

3:57It should send me only to this IP address right here.

4:01And that is actually our server three in our pool.

4:07So when I go back to my Windows test box here momentarily and I bring up the

4:12web and

4:12access 172 16 101 11 which is this IP address of this virtual server.

4:18I should be sent to server three and this information should be logged.

4:22Alright, let's give it a go.

4:24Alright, let's open this up and we should be sent to server three.

4:29There we go.

4:30Server three let's do an incognito.

4:32Server three there we go.

4:34Alright, let me do another one.

4:35Let's do another one.

4:36Let's see new incognito.

4:39And what do I hit the wrong thing?

4:40Alright still server three.

4:41Let's bring our terminal in.

4:43Let's do a tail var log LTM enter.

4:49And we have a log entry here and it says warning generated common Bob redirect

4:54for warning

4:55deprecated usage use else or else if.

5:00So if I go back here let me get this out.

5:03So it did log something it logged in a warning not there and here.

5:07Alright I've got an update here.

5:09I spent some time troubleshooting this error and it turns out I think the cause

5:15was hidden

5:16characters from copy and paste.

5:19So what I did was go through here and erase all of any spaces that were in here

5:24and that

5:24still didn't fix it.

5:26So then what I did was go to virtual servers went into my virtual server and I

5:31had to actually

5:32disable my virtual server right here.

5:35Disable it and save it and then go enable it and save it.

5:37So I had to bounce my virtual server for those changes to take effect.

5:41So again I rules to be honest are hit and miss here because of the intricate

5:46details

5:46of things like that and I should not have to bounce a virtual server to get an

5:50I roll

5:50to work but that's what caused it to work.

5:53So let's go see it in action now that it's fixed.

5:56So if I open this up I should be going to if we go back here to the I roll real

6:00quick.

6:00Let's go to I rules our Bob redirect.

6:04So here I should be redirected to my server 3 and I should have a login tree

6:09that has

6:10this information in it.

6:11Let's go back here and so let's open an incognito and there we go server 3.

6:17Now if I go over here actually here you can't see this is off screen I need to

6:21bring in

6:21the terminal and I go ahead and do my var log LTM I'm going to tail that and

6:28enter and

6:29there we go.

6:30This is the entry this is on my Bob redirect and there you go that is the

6:35logging.

6:36So now we see that that rule is fixed but actually there was nothing wrong with

6:40the

6:40rule evidently it was hidden characters and I had to bounce that virtual server

6:44which

6:44is just really blows my mind.

6:47Okay but moving on let's go back here.

6:52Alright there we go so let's go take a look at another I roll let's go over to

6:55I rolls

6:56here and this is the Bob redirect URI.

6:59Now here what I'm doing is looking at the HTTP request so again I'm going to

7:03need to

7:04have that HTTP profile in use alright and then if HTTP URI that's our web

7:13location after

7:15the URL it's going to be our slash all this stuff okay.

7:20If it equals just a slash which is just the default location go ahead and

7:24redirect it

7:24to the same HTTP host that's what we have here but 50x.html which is an error

7:32file that's

7:33located on our pool members okay.

7:38So this is already on there and that's why I chose it and I wouldn't normally

7:40send somebody

7:41to this location but this file is the only other HTML in the HTML root file on

7:46our test

7:46servers so we're just going to do that.

7:49So let's go ahead and turn this on and I should hit the server and then be

7:52redirected to some

7:54type of error page.

7:55So let's see this go over to our virtual servers.

7:59There we go let's go to HTTP and there we go resources.

8:05Let's go ahead and manage that I'm going to remove the redirect there and I

8:11want the

8:12scroll up there the URI that one redirect URI and finished.

8:17Alright so when I go back to my Windows test box I'm going to close these out.

8:23I should receive an error page.

8:26Now when I go here I'm probably just going to get the standard 3 right because

8:29this is

8:30cached information.

8:32Let me bring up an incognito window and make it a little bigger and hopefully

8:38this works.

8:39Enter oh sure enough there it goes and error occurred and if you look up here

8:44at the URI

8:45it is sending me to 50x.html and this is an error page.

8:50It's not working because so now if I go back to the big IP and I go ahead and I

8:56remove

8:57that I rule manage remove the I rule and I'm actually going to put this other

9:04one either

9:05redirection back in say finished and that's because I want to see if it'll log

9:09this time.

9:10It's just really acting weird.

9:13So we'll go back here and now if I go here and I got to give it a minute I'll

9:17close this

9:17out.

9:19Go back to here and open an incognito and now I should go back to server 3.

9:24So hit enter and back to server 3.

9:27Alright so that wraps up our I rule traffic steering.

9:30Next up is validation.

9:32See you there shortly.

9:32[BLANK_AUDIO]

Validation

0:00Alright, time for validation. So let's go through some validation questions

0:03here. There is a note here

0:04If you do plan on taking the F5LTM specialist exam, you will want to spend some

0:09time in dev central looking at eye rules

0:11I'm telling you you're gonna need to be able to

0:14Know the common commands most common and just be able to

0:18Decipher what an eye rule is trying to do and we're gonna look at a couple of

0:23those down below

0:24So question one your company is rolling out an updated web application at a new

0:29URL

0:29So the new updates going at a new URL

0:32All right, and the old URL is dub dub dub nugget labs.net new URL is dub dub

0:38dub nugget labs.com

0:40So we're going from dot net to dot com

0:42Which of the following eye rules will allow clients to connect to the old URL

0:47and still be able to access the new web app?

0:50Well, the only way that could happen is if when they connect to the old URL,

0:54they're redirected to the new URL

0:56So that's what we're trying to do here take a look at the images below and

0:59choose the answer that

1:01relates to the correct image

1:03Have you seen D? Here we go. Here's some code to look at eye rule number a

1:08when an HTTP request comes in if

1:11The hsp host equals dub dub nugget labs.com

1:18redirect it to nugget labs.net

1:20That's the opposite of what we're trying to do. So that's not gonna work down

1:24here when your HTTP data

1:27Now think about this we're looking for the request that's coming in. We're not

1:36looking for the data

1:37HTTP requests will include the URL which is

1:41nugget labs.com that is the HTTP host value

1:47Okay, so HTTP data ain't gonna cut it because that's not where the information

1:52is we're looking for it

1:53It's in the HTTP request. So this has to start with

1:57When HTTP requests, so let's scroll on down

2:00All right. Oh here C starts with when HTTP requests. That's good

2:05If hsp host equals dub dub nugget labs.net anything send it to nugget labs.com

2:13Well, that kind of would work, but we're looking to only redirect dot net to

2:17dot com all right

2:18So scrolling on down to D this must be the answer when HTTP request the host

2:24equals

2:25dub dub dub dub nugget labs.net

2:28redirect it to dub dub dub nugget labs.com so our answer here is D

2:33That is the correct answer. All right scroll on down to number two

2:39Your company has recently moved this web application to a new location and to

2:43ensure users can still access it at its old location

2:45You set up a redirect on the web application server. That sounds like what we

2:51just did

2:51You've been tasked to setting up an i-roll that will log all of the redirects

2:57so you can ensure it's working properly

2:59So we're really just wanting to log when the redirects happen. So which of the

3:03following i-rolls will do this? Let's find out

3:05down here

3:08When HTTP responds, so let's talk about this and the last one we looked for the

3:12HTTP request

3:14Well, the request is going to have the original destination URL

3:18But when we have a response, that's when we're going to see that redirection

3:21happening

3:22So here we're doing an if if HTTP is

3:263xx

3:28Okay, so only if it's has this these 3xx

3:32Then it will log that it's redirecting the client IP address and it'll put the

3:36IP and remote address in there

3:38All right, let's think about that. Let's compare that to some other options

3:41Now here is when HTTP requests, well, I don't want the request the the red

3:46irection is in the response

3:47So I need to start with when HTTP response. Let me go down

3:51That's another request that can't be it and moving on down to d this should be

3:57it

3:57So when HTTP response if a speed redirects, that means if it's a redirect then

4:03go ahead and log this

4:05Okay, that looks right. So d would be our answer

4:09So again, you need to familiarize yourself with these commands

4:12That's why I threw something here that we didn't see or work with maybe

4:16so that you could kind of

4:18Get the idea

4:19So hopefully you went through and used the documentation

4:23to look up the HTTP request

4:25And some of these other options because that's how we kind of learn through

4:30this because there are so many events and commands

4:33All right on to question three, what an error occurs with an iRIL in production

4:38So that means you're using an iRIL. What will the end result of the connection

4:43be?

4:43Well, the answer is

4:45Let's see the connection will prompt the user to continue

4:48So if they're basically if a user is trying to connect and the iRIL has an

4:52error what's going to happen to that connection

4:54The user will be prompted to continue. No, the connection will send the user a

4:59404 error. No

5:01The connection will be reset. Yes

5:03Most likely it's going to be reset

5:06And that's what's going to happen when you have an iRIL error

5:09Moving down to question four

5:11If your iRIL isn't working as expected

5:15What would you look for in the var log ltm log file that would indicate an iRIL

5:20error?

5:21We talked about this

5:23Remember when we looked at an error, it wasn't an iRIL error. It wasn't an iRIL

5:27error. It was a tickle error. That's right

5:31All right, there we go. That is our review questions

5:34For this skill dealing with iRILs. I hope this has been informative for you and

5:39i'd like to thank you for viewing

5:40[ Silence ]

Team training path

Turn this skill into assignable team training

This free skill is a preview of the courses your team can assign, track, and report on with CBT Nuggets.

What's next?

Ready to keep going?

For your team

Bring this training to your team

See how CBT Nuggets helps IT teams close skills gaps, hit compliance targets, and prove training ROI.

Book a Demo
Just need F5 BIG-IP?

Learning on your own? Browse individual plans ($49/month, billed annually)

Not ready to buy?
with no purchase required. Already have an account?
Book a Demo