Forum Discussion
Can I SNAT UDP traffic using iRule? [for outbound traffic]
Hello Folks,
Can I SNAT UDP (precisely SNMP) using iRule? If yes, could you please share an example how?
Thank you, Darshan
9 Replies
- Kevin_Stewart
Employee
Yes you can, but you shouldn't need an iRule. Assuming you have a UDP VIP assigned to forward this traffic, assign a SNAT pool there.
- swo0sh_gt_13163
Altostratus
Hi Kevin,
Thanks for the answer. However the VS is a forwarding VS for all protocols. We need to SNAT traffic specifically for outbound ICMP and SNMP connections.
Any help?
- Kevin_Stewart
Employee
I would probably do something like this:
when CLIENT_ACCEPTED { switch [IP::protocol] { "1" - "17" { snat automap } } } when CLIENT_DATA { switch [IP::protocol] { "1" - "17" { snat automap } } } - swo0sh_gt_13163
Altostratus
Thanks for this Kevin,
Do I need Client_Accepted and Client_Data both to be mapped within same iRule? I would need to add Client_IP_addr in Client_Accepted, right?
Thank you, Darshan
- Kevin_Stewart
Employee
I would need to add Client_IP_addr in Client_Accepted, right?
Do you need to do this based on the client IP? I'm assuming not.
The above is one iRule that should be applied to the forwarding VIP. You need both the CLIENT_ACCEPTED and CLIENT_DATA events because UDP's statelessness won't always trigger a CLIENT_ACCEPTED event.
- swo0sh_gt_13163
Altostratus
Sorry, I think I didn't explain the exact requirement.
I have 3 IP addresses which I want to SNAT, only for ICMP and SNMP for outbound connection.
I made a rule as following which doesn't seem effective, not sure why.
when CLIENT_ACCEPTED { if { ([IP::addr [IP::client_addr] equals 10.254.47.12/32] or [IP::addr [IP::client_addr] equals 10.254.47.13/32]) and [TCP::local_port] == 161 }{ snat 10.254.55.65 } else { forward } } - Kevin_Stewart
Employee
Try this:
when CLIENT_ACCEPTED { if { ( [IP::addr [IP::client_addr] equals 10.254.47.12/32] or [IP::addr [IP::client_addr] equals 10.254.47.13/32] ) } { switch [IP::protocol] { "1" - "17" { snat automap } } } } when CLIENT_DATA { if { ( [IP::addr [IP::client_addr] equals 10.254.47.12/32] or [IP::addr [IP::client_addr] equals 10.254.47.13/32] ) } { switch [IP::protocol] { "1" - "17" { snat automap } } } } - swo0sh_gt_13163
Altostratus
Perfect!
Thanks a ton!! Btw, where can I get the list of protocol number listed in your iRule?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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