Forum Discussion
Rob_78590
Nimbostratus
Aug 25, 2009iRule for SNAT for Host IPs & Supernets based on specific customer
Hi everyone! We currently have an iRule setup to SNAT to a particular IP depending on which customer it is. We specify the customer's host address in the Data Group List and associate it to our IP that we would like to SNAT to. The iRule listed below currently works for host IPs, however, it does not support Supernets. Does anyone know how to modify the below iRule to also include Supernets for customers who may have a large block of addresses?
when CLIENT_ACCEPTED {
set syn_snat [findclass [IP::local_addr] $::syniverse_snat " "]
if { $syn_snat ne ""} {
snat $syn_snat
}
}
- The_Bhattman
Nimbostratus
Can you post the structure of the datagroup? - hoolio
Cirrostratus
I'd guess the current format is just a host and the corresponding SNAT IP:when CLIENT_ACCEPTED { log local0. "[IP::client_addr]:[TCP::client_port]: New connection. Using class: $::ip_snat_class" Loop through each line in the datagroup foreach line $::ip_snat_class { Log the current line by field log local0. "\$line: $line, IP: [lindex $line 0], SNAT: [lindex $line 1]" Check if the client IP equals the current line's subnet if {[IP::addr [client_addr] equals [lindex $line 0]]}{ log local0. "[IP::client_addr]:[TCP::client_port]: Matched [lindex $line 0], using SNAT [lindex $line 1]" Use the SNAT IP snat [lindex $line 1] Exit the loop as we've found a match break } } }
- Rob_78590
Nimbostratus
Hi Aaron (Hoolio), - hoolio
Cirrostratus
Hi Rob, - Rob_78590
Nimbostratus
Hi Aaron, - hoolio
Cirrostratus
I don't think so. The IP::addr command can be used to evaluate whether an IP address or subnet equals another IP address or subnet. - Rob_78590
Nimbostratus
- hoolio
Cirrostratus
Hi Rob, - Rob_78590
Nimbostratus
Hi Aaron,
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