Forum Discussion
Brad_Wood_7735
May 31, 2007Historic F5 Account
NAT Irule
I have a client that wants to do the following… The "had" this functionality in some alteons that we replaced. Not sure of how to write this irule up, looking for some guidance from the experts!! T...
hoolio
Cirrostratus
Jun 01, 2007You can test how to get the last octet of the destination IP with something like this:
when RULE_INIT {
set ::translated_ip_prefix "1.2.3."
set destination_ip 10.20.30.40
set last_octet [getfield $destination_ip "." 4]
set translated_ip $::translated_ip_prefix$last_octet
log local0. "\$translated_ip: $translated_ip"
}
(logs: $translated_ip: 1.2.3.40)
You could then use a rule like this on a fastL4 network VIP:
when RULE_INIT {
set ::translated_ip_prefix "10.20.30."
}
when CLIENT_ACCEPTED {
node $::translated_ip_prefix[getfield [IP::local_addr] "." 4] [TCP::local_port]
log local0. "Translated IP: $::translated_ip_prefix[getfield [IP::local_addr] "." 4] [TCP::local_port]"
}
I didn't test this, but it passed a syntax check.
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