# Selective SNAT problem

**URL:** <https://community.f5.com/t/selective-snat-problem/30136>\
**Category:** Technical Forums\
**Tags:** irules, ltm, application-delivery\
**Created:** [July 7, 2016, 7:18pm UTC](https://community.f5.com/t/selective-snat-problem/30136 "2016-07-07T19:18:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blahblahdab1ah](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@blahblahdab1ah](https://community.f5.com/u/blahblahdab1ah)\
**Post date:** [July 7, 2016, 7:18pm UTC](https://community.f5.com/t/selective-snat-problem/30136/1 "2016-07-07T19:18:52Z")

</div>

I have a node in a pool trying to reach a virtual server that references the same pool. Using the code below does work with one caveat: the node in the pool can only reach itself.

If the service on the node is disabled, the connection wont get made.

Basically I need it to load balance between the other nodes in the pool in case the service on the node gets compromised. [Here is where I pulled the general code](https://devcentral.f5.com/codeshare/selective-snat).

Specifically, this portion:

" And another option for using SNAT only if the client IP is a node in the pool:

when CLIENT\_ACCEPTED { Check if the client IP address is a node in the VIP’s default pool if {[matchclass [IP::client\_addr] equals [active\_nodes -list [LB::server pool]]]}{

```tcl
log local0. "SNAT'ing for [IP::client_addr], member of pool [LB::server pool]"
  snat automap

```

} }"

Thanks!

---

<div class="post-metadata">

**Author:** ![DevBabu](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@DevBabu](https://community.f5.com/u/DevBabu)\
**Post date:** [July 7, 2016, 7:33pm UTC](https://community.f5.com/t/selective-snat-problem/30136/2 "2016-07-07T19:33:48Z")

</div>

Let’s take a packet capture.

tcpdump -ni 0.0:nnnp -s0 -w /var/tmp/snat.pcap host -vvv

---

<div class="post-metadata">

**Author:** ![blahblahdab1ah](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@blahblahdab1ah](https://community.f5.com/u/blahblahdab1ah)\
**Post date:** [July 7, 2016, 9:11pm UTC](https://community.f5.com/t/selective-snat-problem/30136/3 "2016-07-07T21:11:29Z")

</div>

This is the version that worked in this scenario:

when LB\_SELECTED {

if {[IP::addr “[IP::client\_addr]/24” equals “[LB::server addr]/24”]} {

snat automap } }

Thanks for the help!
