I’m pretty new to the BIG-IP load balancers. We have a couple servers on which we have SharePoint sites load balanced. The load balancing appears to work fine. Obviously, I’ve set up a Virtual Server with a virtual IP, so when users connect to a site, for instance sitename.domain.net, they will connect to the IP of the virtual server and get load balanced. However, we talked about being able to ping the sitename.domain.net from a specific workstation and getting the IP address of the member server to whichthe specific workstation is connected currently to aid in troubleshooting, instead of the IP of the Virtual Server configured on the load balancer. The SharePoint admins say they saw this when we initially set up the Virtual Server, and I’ve not made any changes on the load balancer since. We did make some DNS tweaks, but I don’t see where this would have enabled them to tell which member a specific workstation is connected to. I’m thinking we could set up an iRule for this, but again I’m new to the F5. Any ideas? Maybe there is an easier way? Thanks.
You could use something simple like this to simply insert the selected server IP address in a header in every server response and use something like IEHeaders, HTTPWatch or LiveHTTPHeaders on the client to read it’s value;
when HTTP_RESPONSE {
HTTP::header insert Via "[LB::server addr]"
You could also replace the Server header if it is present
}
Or you could use something a little more complex to send the data in response to a specific request URI:
when LB_SELECTED {
set whichserver [LB::server addr]
}
when HTTP_REQUEST {
if { string tolower [HTTP::uri] equals "/whichserver" } {
HTTP::respond 200 content "Real server IP is: $whichserver" noserver Content-Type
"text/html" Connection "Close"
Stop processing the iRule for this event here
return }
}
I would like to send a txt message to my unix team when I hit LB_FAILED messages in /var/log/tmm (Only when no nodes available) Any help is appreciated
Gopal, please start a new topic rather than posting in unrelated existing (and unresolved) ones.
Thanks Steve. I can see where those would be helpful, however the HTTP tools look like they would cost us, as the free version limits the number of sites. Using “ping” would be free
If there is an iRule that will accomplish responding with the host IP from the client workstation when it pings the site being load balanced. Our Sharepoint admin says he was initially seeing pings of the host IP addresses in the pool, rather than the virtual IP address of the pool for the Sharepoint site, when he would ping from a client. I’ve not changed a setting, so is there some setting on the load-balance, via i-Rule or otherwise that would make this work?
if you want to access server in pool using ip, is network ip forwarding virtual server usable?
sol7595: Overview of IP forwarding virtual servers
I would like to send a txt message to my unix team when I hit LB_FAILED messages in /var/log/tmm (Only when no nodes available) Any help is appreciatedis remote log command (in irule) or custom syslog-ng usable? Colin and Deb have written great articles about logging and syslog-ng as following.
The101: iRules 101 - Logging & Comments by Colin
https://devcentral.f5.com/s/articles/the101-irules-101-logging-amp-comments
LTM 9.4.2+: Custom Syslog Configuration by Deb
I may be mistaken but if you PING the Virtual Server you will never get responses from the Pool Member. I’m not 100% as I guess there’s a chance this might occur with a Layer 2 Forwarding VS.
LiveHTTPHeaders and IEHTTPHeaders are both free to use from what I can see, even for commercial use.
Thanks all. I’ll look closer at the HTTP header tools. The one had a free version, but said it was limited to the number of sites you could configure to use it (as I understood what I read), and potentially we will eventually have a large number of sites. Also, it requires an install on the client workstation, and I think our application guys are wanting something that is quickly reviewable.
I’ll look at the forwarding information.
In the meantime I’ve been looking at iRules and found one that perhaps I could adapt to just log the information on the load balance system log. The iRule below is not complete though. I’d like to set up each iRule for the Sharepoint Sites only that we load balance, and don’t know how to do that. Basically I’d like each time someone connects to a load balanced Sharepoint site virtual IP address pool that the client’s IP address and the address of the physical host server gets logged as an informational message in the F5 logs. I think the iRule below will work, except I’m still researching how to only use the rule for Sharepoint sites. I figure there is a rule where I can say if a “CLIENT ACCEPTED” occurs to a specific vip, but potentially we will have dozens of VIPs in the future, so I could have a lot of iRules to manage. Is there a way to look at Client Accepted connections for only a type of pool? We’re using the Sharepoint templates.
rule SharePoint_sitename{
when CLIENT ACCEPTED {
set remote [IP::remote_addr]
set cip [IP::client_addr]
log local.info “Connection Sharepoint_sitename From $cip to $remote”
Whoops forgot the ending brackets:
rule SharePoint_sitename{
when CLIENT ACCEPTED {
set remote [IP::remote_addr]
set cip [IP::client_addr]
log local.info “Connection Sharepoint_sitename From $cip to $remote”
}
}
LiveHTTPHeaders for Firefox is just an add-in install so probably your best bet.
The iRule needs to be assigned to specific Virtual Servers so you can decide which will log or won’t.
It’s too early to log the selected Pool Member in the CLIENT_ACCEPTED event. How about this (but test carefully, this could overwhelm your device if the connection count is high);
when LB_SELECTED {
log local0. "Client [IP::addr [IP::client_addr] connected to real server IP: [LB::server addr]"
}
Thanks Steve. Would the format be more like this though? I think there’s some extra around the Client IP part as the iRules errored when I tried to set one up.
when LB_SELECTED {
log local0. “Client IP:[IP::client_addr] connected to real server IP: [LB::server addr]”
}
Also, just for my learning, when you say “It’s too early to log the selected Pool Member in the CLIENT_ACCEPTED event.” So the “CLIENT ACCEPTED” event is simply tied to the Load Balancer accepting the connection from the client, and at that point the LB has not yet connected the client to a member of the pool to determine a destination host IP? And I see where to assign the iRule to the Virtual Servers now, which for some reason I overlooked before.
For troubelshooting and debugging, inserting a header in evey resposne is the best option. The devoloper can tell directly, frrom his Firefox, which server is bahaving differently, without the need to inspect logs and trying to correlate his requests amongst potentially thousands others happening at the same time.
I do this on one of my sites and I dont insert the actual backend server IP, pool name and so on, but just code that we can easly decode back.
Thanks,
Mohamed.
The original iRule is correct although your version might still work.
Yes, you are correct regarding the events.
When I try to save the iRule as it is written I get this on the Load Balancer:
error: line 2: [parse error: missing close-bracket] [[IP::addr [IP::client_addr] connected to real server IP: [LB::server addr]" ]
It’s set up like this in the LB. Am I missing something in the format?
when LB_SELECTED {
log local0. “Client [IP::addr [IP::client_addr] connected to real server IP: [LB::server addr]”
}
To change it I simply took out the "[IP::addr ", and changed it to “IP” and it seemed to save without error. Again, I’m new, so I’m not sure which format is ultimately correct. Thanks.
when LB_SELECTED {
log local0. “Client IP:[IP::client_addr] connected to real server IP: [LB::server addr]”
}
Your last code is correct.
Think of it this way (for more details google for TCL tutorials) :
you are callling a “function” called “log”
passing it two arguments, “local0.” and a string.
The sting contains “expressions”, the stuff between [], which are executed and replaced with the result of the expressions.
Your two expressions inside the string above are calls to the following functions:
Thanks,
Mohamed.
The logging of the Client IP is working with this code below, thanks Mohamed and Steve. However, it seems I can’t give the Sharepoint admins access to view the logs on the BIG-IP without giving them administrator access to the device, which I don’t want to do.
when LB_SELECTED {
log local0. “Client IP:[IP::client_addr] connected to real server IP: [LB::server addr]”
}
So, I’ve been working on the HTTP header as Steve suggested, so they could use HTTPWatch, even Wireshark, to review the HTTP headers from response to seek the IP address of the member of the pool to which the client connected. However, I get syntax errors trying to save the code below as an iRule, and when I try to tweak it myself to where I finally get the iRule to save without error, when I try to connect to the Sharepoint site I basically get “the website cannot be found” in Internet Explorer. Once I remove the iRule I can hit the site. So, I’m not sure what I need to adjust so that I can get the IP address of the member server to which the client connected without using the logfiles on the BIG-IP. I’d like to set up something that the Sharepoint admins can access to review without giving them Admin access to the BigIP. I know the sharepoint servers that are members of the pool have IIS logs that will show the IP address of the connecting client, but in this case the IIS logs just show the IP address of the load balancer, rather than the client workstation, so even if there is a way to pass the Client IP through without messing with connectivity?
when LB_SELECTED {
set whichserver [LB::server addr]
}
when HTTP_REQUEST {
if { string tolower [HTTP::uri] equals “/whichserver” } {
HTTP::respond 200 content “Real server IP is: $whichserver” noserver Content-Type
“text/html” Connection “Close”
Stop processing the iRule for this event here
return }
}
The logging of the Client IP is working with this code below, thanks Mohamed and Steve. However, it seems I can’t give the Sharepoint admins access to view the logs on the BIG-IP without giving them administrator access to the device, which I don’t want to do.
when LB_SELECTED {
log local0. “Client IP:[IP::client_addr] connected to real server IP: [LB::server addr]”
}
So, I’ve been working on the HTTP header as Steve suggested, so they could use HTTPWatch, even Wireshark, to review the HTTP headers from response to seek the IP address of the member of the pool to which the client connected. However, I get syntax errors trying to save the code below as an iRule, and when I try to tweak it myself to where I finally get the iRule to save without error, when I try to connect to the Sharepoint site I basically get “the website cannot be found” in Internet Explorer. Once I remove the iRule I can hit the site. So, I’m not sure what I need to adjust so that I can get the IP address of the member server to which the client connected without using the logfiles on the BIG-IP. I’d like to set up something that the Sharepoint admins can access to review without giving them Admin access to the BigIP. I know the sharepoint servers that are members of the pool have IIS logs that will show the IP address of the connecting client, but in this case the IIS logs just show the IP address of the load balancer, rather than the client workstation, so even if there is a way to pass the Client IP through without messing with connectivity?
when LB_SELECTED {
set whichserver [LB::server addr]
}
when HTTP_REQUEST {
if { string tolower [HTTP::uri] equals “/whichserver” } {
HTTP::respond 200 content “Real server IP is: $whichserver” noserver Content-Type
“text/html” Connection “Close”
Stop processing the iRule for this event here
return }
}
It could be that you’ve used a line break that shouldn’t be there on the line with HTTP::respond, it should all be one line. If it is still an issue, maybe it’s the event order and we should skip one;
when HTTP_REQUEST {
if { string tolower [HTTP::uri] equals "/whichserver" } {
HTTP::respond 200 content "Real server IP is: [LB::server addr]" noserver Content-Type "text/html" Connection "Close"
Stop processing the iRule for this event here
return }
}