ltm rule command IP local addrΒΆ

iRule(1)		      BIG-IP TMSH Manual		      iRule(1)



IP::local_addr
       Returns the IP address of the virtual server the client is connected to
       or the self-ip LTM is connected from.

SYNOPSIS
       IP::local_addr (clientside | serverside)?

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 in the
       x.x.x.x%rd format.

       This command is equivalent to the BIG-IP 4.X variable local_addr.

RETURN VALUE
       Returns the IP address being used in the connection.

VALID DURING
       CLIENT_ACCEPTED, CLIENT_CLOSED, HTTP_REQUEST, HTTP_REQUEST_DATA,
       HTTP_REQUEST_SEND, HTTP_RESPONSE, HTTP_RESPONSE_DATA, IP_GTM,
       LB_SELECTED, SERVER_CLOSED, SERVER_CONNECTED

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]"
	}

HINTS
SEE ALSO
CHANGE LOG
       @BIGIP-9.2.2 -- Add to GTM @BIGIP-9.0.0 --First introduced the command.



BIG-IP				  2017-01-31			      iRule(1)