Forum Discussion
Dan_Deming_1935
Nimbostratus
Aug 18, 2006How do I insert LB's IP with an irule?
We have 2 F5 Big IP units set up in front of 3 web servers running Apache 1.3. We're using the Type: Standard, Protocol: TCP and HTTP Profile: HTTP settings.
In our Apache logs, we want to include the IP address of the client, the IP of the server and the IP of the F5 unit. I was able to set up this irule to get the first 2:
when HTTP_REQUEST {
HTTP::header insert "Remote-Addr" [IP::remote_addr]
HTTP::header insert "Local-Addr" [IP::local_addr]
}
Adding IP::client_addr gives the same value as local_addr, and trying to use IP::server_addr actually breaks the web page: a Page cannot be displayed error is shown. I know I can hardcode in different values in the irule:
HTTP::header insert "LB" LB1
However, since we want to sync both LBs and have the exact same config on both machines, this isn't feasible. I spoke with customer support who said they knew of no unique identifier I could use, and no way to get the LB's IP. Is there any way to get this information and put it in a header? Can you use envirnonment variables in a header, so I can print the $hostname to the header?
Any help would be greatly appreciated. Thanks.
- Which IP of the BIG-IP are you looking at inserting? The Management port, the IP of the virtual, or the internal gateway address that is used to connect to your backend servers?
when HTTP_REQUEST { set bigip_addr [IP::local_addr] } when HTTP_REQUEST_SEND { clientside { HTTP::header insert "Client-Addr" [IP::client_addr] HTTP::header insert "BIGIP-Addr" $bigip_addr HTTP::header insert "Node-Addr" [IP::remote_addr] } }
- hoolio
Cirrostratus
Nice trick with clientside. I was getting a context error when trying to insert a header in the HTTP_REQUEST_SEND event. - It has to do with which context owns the data and in the case of http requests, it's the clientside context. The HTTP_REQUEST_SEND event lives in the serverside context so any commands you issue with be processed there without the clientside override.
- Dan_Deming_1935
Nimbostratus
I still can't get the Big IP's IP address to be passed on.when HTTP_REQUEST { set bigip_addr1 [IP::local_addr] set bigip_addr2 [IP::remote_addr] set bigip_addr3 [IP::client_addr] } when HTTP_REQUEST_SEND { set serverip_addr1 [IP::server_addr] set remoteip_addr2 [IP::remote_addr] set clientip_addr3 [IP::client_addr] clientside { HTTP::header insert "Client-Addr" [IP::client_addr] HTTP::header insert "Server-Addr" [IP::server_addr] HTTP::header insert "Node-Addr" [IP::remote_addr] HTTP::header insert "Local-Addr" [IP::local_addr] HTTP::header insert "BIGIP-Server-Addr" $serverip_addr1 HTTP::header insert "BIGIP-Remote-Addr" $remoteip_addr2 HTTP::header insert "BIGIP-client-Addr" $clientip_addr3 HTTP::header insert "BIGIP1" $bigip_addr1 HTTP::header insert "BIGIP2" $bigip_addr2 HTTP::header insert "BIGIP3" $bigip_addr3 } }
- hoolio
Cirrostratus
I think if you use [IP::local_addr] in the HTTP_REQUEST_SEND event it should get you the SNAT or source IP the BIG-IP will use to source the traffic to the node. - hoolio
Cirrostratus
To clarify...... when HTTP_REQUEST_SEND { set bigip_source_to_node [IP::local_addr] ... clientside { HTTP::header insert "Source_to_node" $bigip_source_to_node ... } }
- unRuleY_95363Historic F5 AccountUnfortunately, we don't have a mechanism for accessing the BIGIP's mgmt IP address nor any of the Self IP's.
- unRuleY_95363Historic F5 AccountHoolio: I'm assuming snat must not be enabled, and that's why IP::local_addr is reflecting the client's IP address in HTTP_REQUEST_SEND...
- Dan_Deming_1935
Nimbostratus
unRuleY,class whichlb { "/config/whichlb.txt" } when HTTP_REQUEST { HTTP::header insert "Remote-Addr" [IP::remote_addr] HTTP::header insert "Local-Addr" [IP::local_addr] HTTP::header insert "LB" $::whichlb }
- unRuleY_95363Historic F5 AccountI'm assuming your not defining the class in the iRule...
class whichlb { type string filename "/config/whichlb.txt" }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects