Forum Discussion

LeonSmirnov's avatar
LeonSmirnov
Icon for Nimbostratus rankNimbostratus
Nov 05, 2020

I iRule

We are creating new wildcard virtual server with source and destination 0.0.0.0/0 and service port * (any).

 

We will need to forward traffic with client IP address (no Source Address Translation) to different pools.

Forwarding decisions must be based on destination IP and destination port and some also based on source address

Something like this:

1) If client IP is 10.11.0.0/16, destination IP 172.168.1.11 and destination port is 5555 then forward traffic to Pool1

2) All other clients If destination IP 172.168.1.11 and destination port is 5555 then forward traffic to Pool2

3) If destination IP 10.1.1.1 and destination port is 4444 then forward traffic to Pool3

3) All other traffic forward to WildCard-Pool (configured as pool for WildCard server)

 

We tried to do it with traffic policy, but it did not work and requires HTTP profile on Virtual Server (some of the traffic is not HTTP, it could be HTTPS or custom application)

 

Could somebody provide me iRule that I could use to forward this traffic or suggest any other way to configure this?

1 Reply

  • Hello Leon.

    You can use this iRule:

    when CLIENT_ACCEPTED {
    	set client_ip [clientside {IP::remote_addr}]
    	set client_port [clientside {TCP::remote_port}]
    	set vs_ip [clientside {IP::local_addr}]
    	set vs_port [clientside {TCP::local_port}]
     
    	if { ([ IP::addr $vs_ip eq 172.168.1.11 ]) && ($client_port eq "5555") } {
    		if { [ IP::addr $client_ip eq 10.11.0.0/16 ] } {
    			pool Pool1
    		} else {
    			pool Pool2
    		}
    	}
    	if { ([ IP::addr $vs_ip eq 10.1.1.1 ]) && ($client_port eq "4444") } {
    		pool Pool3
    	} 
    }

    WildCard-Pool should be assigned to the defaul pool configuration in the VS settings.

    Regards,

    Dario.