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

Filter by:
  • Solution
  • Technology
Answers

Virtual Server IP Address in SERVER_DATA event

We have a straight up load balancing VS for UDP DNS running on an LTM license. To meet some logging and analytic requirements, I want to include the IP address of the VS inside the SERVER_DATA event. According to the documentation, IP::local_addr and IP::server_addr will report the BIGIP source IP or SNAT (depending on configuration). I can't locate a way to reference the VS address...can get it in the CLIENT_DATA event, however the SERVER_DATA event is elusive. Is there a method to get the VS address inside SERVER_DATA? I've examined using a global variable set in CLIENT_DATA event, however that kills CMP and as this is expected to have performance ramifications I'd rather avoid.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You don't need a global variable to pass the virtual server IP address from the CLIENT_DATA event to the SERVER_DATA event. A local variable will work just fine. For example:

when CLIENT_DATA { set vipAddress [IP::local_addr] }

when SERVER_DATA { log local0. "Client is connected to $vipAddress" }

In other words, set variable vipAddress on the CLIENT_DATA event, and refer to the variable as $vipAddress on the SERVER_DATA event.

0
Comments on this Answer
Comment made 10-Feb-2018 by Jon Macy 68

That worked fine thank you. So "local" scope is the entire iRule and not just within a given event?

0
Comment made 10-Feb-2018 by crodriguez

Yes, the scope of a local variable is not just within a given event. In fact, the scope of a local variable is across all iRules applied to a virtual server for the life of a single connection. In other words, if you have two or more iRules on a single virtual server, then a local variable named $vipAddress referred to in any of those iRules is the same variable on any given connection.

0