Forum Discussion
felix001_29321
Nimbostratus
Sep 27, 2011Irule TCP Port Issue
Im trying to create an Irule which will snat the connection behind a single ip when destined for a destination port.
The iRule I have is :
-------------------------------------------------
when CLIENT_ACCEPTED {
if { [matchclass [IP::client_addr] equals $::src_nets ] and [[TCP::remote_port] equals "8181" ] } {
snat 172.16.1.100
}
else {
forward
}
}
--------------------------------------------------
The doesnt work. Ive tested it with just the matchclass and it works.
Many Thanks,
- Michael_Yates
Nimbostratus
Hi Felix,when CLIENT_ACCEPTED { if { [matchclass [IP::client_addr] equals $::src_nets ] and [[TCP::local_port] equals "8181" ] } { snat 172.16.1.100 } }
- felix001_29321
Nimbostratus
My version is v10.x.x.x. But the match class by itself works ?? its the destination port section Im having issues with ... - Michael_Yates
Nimbostratus
Hi Felix,when HTTP_REQUEST { if { [class match [IP::client_addr] equals src_nets ] and [[LB::server port] equals "8181" ] } { snat 172.16.1.100 } }
- hoolio
Cirrostratus
Hi Michael,when HTTP_REQUEST { if { [class match [IP::client_addr] equals src_nets ] and [TCP::local_port] == 8181 } { snat 172.16.1.100 } }
- Michael_Yates
Nimbostratus
I actually tested it to make sure it works in the HTTP_REQUEST Event. - hoolio
Cirrostratus
Hrm... [LB::server] and [LB::server pool] return the VS default pool name before a load balancing selection has been made (normally in LB_SELECTED). I wonder what LB::server port actually returns before a load balancing selection has been made. Is it the client destination port or a port of one of the pool members? I'm guessing the former, but it's not very intuitive that the command would even work as it should return info on the load balancing selection. - Michael_Yates
Nimbostratus
The environment I tested the even in had the request incoming on Port 80, with Port Translation enabled.when CLIENT_ACCEPTED { if { [LB::server port] equals "8181" } { log local0. "Client Accepted Event: LB Selected Server: [LB::server] / Selected Port: [LB::server port]" } } when HTTP_REQUEST { if { [LB::server port] equals "8181" } { log local0. "HTTP Request Event: LB Selected Server: [LB::server] / Selected Port: [LB::server port]" } }
- felix001_29321
Nimbostratus
Thanks for your responses guys. So to clarify if Im adding this to a forwarding virtual server I just need to addwhen HTTP_REQUEST { if { [class match [IP::client_addr] equals src_nets ] and [TCP::local_port] == 8181 } { snat 172.16.1.100 } }
- felix001_29321
Nimbostratus
So guys want it the option for when non http traffic just going via the VS forwarder !? - hoolio
Cirrostratus
You could use CLIENT_ACCEPTED for non-HTTP traffic.when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals src_nets ] and [TCP::local_port] == 8181 } { snat 172.16.1.100 } }
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