IP::local_addr

Description

When called in a clientside context, this command returns the IP address of the virtual server the client is connected to. When called in a serverside context it returns the self-ip address or spoofed client IP address LTM is using for the serverside connection.
This command is primarily useful for generic rules that are re-used. Also, it is useful in reusing the connected endpoint in another statement (such as with the listen command) or to make routing type decisions. You can also specify the IP::client_addr and IP::server_addr commands.
This command in BIG-IP 10.x returns identical output as BIG-IP 9.x if the IP address of virtual or self-ip is in the default route domain else it returns the IP address as well as the route domain the x.x.x.x%rd format.
This command is equivalent to the BIG-IP 4.X variable local_addr.

Syntax

IP::local_addr

IP::local_addr

  • Returns the IP address being used in the connection. In the clientside context, this is the destination IP address from the client request (not necessarily the virtual IP address). In the serverside context, this is the source IP address (SNAT address if SNAT is used, else spoofed client IP address).

Examples

when CLIENT_ACCEPTED {
  if { [IP::addr [IP::local_addr] equals 172.16.32.2] } {
     pool deprecated_site
  } else {
     pool current_site_pool
 }
}

In BIG-IP 10.x with a virtual address in a route domain matching the x.x.x.x%rd format
when CLIENT_ACCEPTED {
  if { [IP::addr [IP::local_addr] equals 172.16.32.2%1000] } {
     pool deprecated_site
  } else {
     pool current_site_pool
 }
}

In BIG-IP 10.x with a virtual address in a route domain matching the IPv4 portion of the IP::local_addr
when CLIENT_ACCEPTED {
  if { [IP::addr [getfield [IP::local_addr] "%" 1] equals 172.16.32.2] } {
     pool deprecated_site
  } else {
     pool current_site_pool
 }
}

when SERVER_CONNECTED {
   log local0. "Source IP address for connection to node: [IP::local_addr]"
}

In BIG-IP 10.x with a self-ip in a route domain, prints only the IPv4 portion of the address
when SERVER_CONNECTED {
   log local0. "Source IP address for connection to node: [getfield [IP::local_addr] "%" 1]"
}