Creating a dynamic one-to-one SNAT pool

We have a problem with an SMB VIP that appears to be NAT related. What we are looking to do is create a SNAT pool in which each new IP address is assigned it’s own SNAT address.

Is there any simple way to do this or do I need to create an Irule that will create SNAT entries on the fly and keep track of which ones are already set up?

You will most likely need to use an iRule. Are you looking to map a /24 to a /24 or something similar? If so, you could write an iRule that can SNAT 10.0.0.x to 192.168.0.x, for example, by just translating the last digit of the address.

You will most likely need to use an iRule. Are you looking to map a /24 to a /24 or something similar? If so, you could write an iRule that can SNAT 10.0.0.x to 192.168.0.x, for example, by just translating the last digit of the address.

No. Basically we are having a problem in which NAT is confusing our server and dropping connections. Basically it is having trouble with multiple users connecting with the same source IP. So we want to create a pool in which each user will be assigned a unique source IP address so the NAT isn’t overloaded.

No. Basically we are having a problem in which NAT is confusing our server and dropping connections. Basically it is having trouble with multiple users connecting with the same source IP. So we want to create a pool in which each user will be assigned a unique source IP address so the NAT isn’t overloaded.

Well that seems like a bad problem to have for the server to have. You will run out of IPs quickly, if the application is going to require a unique IP per session. What kind of application/web server are you running? Is it having NAT problems or port exhaustion problems?

Well that seems like a bad problem to have for the server to have. You will run out of IPs quickly, if the application is going to require a unique IP per session. What kind of application/web server are you running? Is it having NAT problems or port exhaustion problems?

It isn’t that bad a problem but it is a problem. This is an internal service so the number of users is limited to a few hundred. We will just glom a 10./8 address block and use that. What is being alleged is that the LB NAT of the connections is making the server drop connections. If you want a more detailed explanation it is based on this writeup… http://www.nynaeve.net/?p=93 We aren’t 100% certain that this is the problem but we did see several writeups similar to this one and they all describe the problem we see.

It isn’t that bad a problem but it is a problem. This is an internal service so the number of users is limited to a few hundred. We will just glom a 10./8 address block and use that. What is being alleged is that the LB NAT of the connections is making the server drop connections. If you want a more detailed explanation it is based on this writeup… http://www.nynaeve.net/?p=93 We aren’t 100% certain that this is the problem but we did see several writeups similar to this one and they all describe the problem we see.

Not sure if this will work, but trying to get creative as picking an IP from a list based on availability may be cumbersome in the iRule. What you could try is to set the VIP to the actual IP of your SMP server and turn off “Address Translation” on that VIP. Create a pool of nodes using all the IPs you want to use for your SNATs. Set the connection limit for each pool member to 1 and use this in an iRule; when CLIENT_ACCEPTED { snat [IP::server_addr] }. This could leverage LTMs built in connection table to track your SNATs is a creative way. I haven’t tried this, but I am doing something similar in a dev environment.

Not sure if this will work, but trying to get creative as picking an IP from a list based on availability may be cumbersome in the iRule. What you could try is to set the VIP to the actual IP of your SMP server and turn off “Address Translation” on that VIP. Create a pool of nodes using all the IPs you want to use for your SNATs. Set the connection limit for each pool member to 1 and use this in an iRule; when CLIENT_ACCEPTED { snat [IP::server_addr] }. This could leverage LTMs built in connection table to track your SNATs is a creative way. I haven’t tried this, but I am doing something similar in a dev environment.

That is an interesting way of doing it. I would need to add each node one at a time that way, wouldn’t I? How would it know to use the pool of IPs?

That is an interesting way of doing it. I would need to add each node one at a time that way, wouldn’t I? How would it know to use the pool of IPs?

I would try it out with just a couple IPs first, but essentially you could create all the nodes you need via tmsh scripting and add them all to the pool assigned to the VIP.

I would try it out with just a couple IPs first, but essentially you could create all the nodes you need via tmsh scripting and add them all to the pool assigned to the VIP.

Brad,

I am going to try this but if that doesn’t work I’m thinking it might be easier for me to create a replace mask. So I have incoming request of 10.99.99.23 I could do a replacement mask of 172.23.. it would replace the source with 172.23.99.23.

While this won’t guarantee unique source IP addresses, it should greatly reduce the problem.

How do I apply the pool to the SNAT? I’m a little confused about that. Wouldn’t snat [IP::server_addr] assign the SNAT to be the destination server address?

So what I suggested doesn’t quite work the way I had hoped, but it can be “made” to work but it then gets to be more of a hacked together solution then its worth. You are probably better of doing a replacement mask like I first suggested and you suggest here. That’s a far better and simple solution if you must SNAT the traffic to the SMB server. Alternatively if the LTM was the default gateway you would not need to SNAT that traffic at all.

How do I apply the pool to the SNAT?

you can use simple irule something like this. you also need to make sure server knows where to send return traffic e.g. routing, arp.

configuration

root@(ve11b)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.24.10:80
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        fastL4 { }
    }
    rules {
        qux
    }
    source 0.0.0.0/0
    vs-index 6
}
root@(ve11b)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
    members {
        200.200.200.101:80 {
            address 200.200.200.101
        }
    }
}
root@(ve11b)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
    when CLIENT_ACCEPTED {
  scan [IP::client_addr] %*d.%*d.%d.%d c d
  snat 192.168.$c.$d
}
}

 trace

[root@ve11b:Active:In Sync] config  tcpdump -nni 0.0 port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on 0.0, link-type EN10MB (Ethernet), capture size 96 bytes
13:38:36.981475 IP 172.28.24.1.50638 > 172.28.24.10.80: S 2519421337:2519421337(0) win 5840 
13:38:36.981607 IP 192.168.24.1.50638 > 200.200.200.101.80: S 2519421337:2519421337(0) win 5840

How do I apply the pool to the SNAT?

you can use simple irule something like this. you also need to make sure server knows where to send return traffic e.g. routing, arp.

configuration

root@(ve11b)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.24.10:80
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        fastL4 { }
    }
    rules {
        qux
    }
    source 0.0.0.0/0
    vs-index 6
}
root@(ve11b)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
    members {
        200.200.200.101:80 {
            address 200.200.200.101
        }
    }
}
root@(ve11b)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
    when CLIENT_ACCEPTED {
  scan [IP::client_addr] %*d.%*d.%d.%d c d
  snat 192.168.$c.$d
}
}

 trace

[root@ve11b:Active:In Sync] config  tcpdump -nni 0.0 port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on 0.0, link-type EN10MB (Ethernet), capture size 96 bytes
13:38:36.981475 IP 172.28.24.1.50638 > 172.28.24.10.80: S 2519421337:2519421337(0) win 5840 
13:38:36.981607 IP 192.168.24.1.50638 > 200.200.200.101.80: S 2519421337:2519421337(0) win 5840

Using exactly this approach (with “getfield” but “scan”; but like the scan-based approach better (+1)) in a client´s environment. No problems by now and client has a one-by-one mapping allowing simplified troubleshooting. As nitass already pointed out, make sure to have a route back to the virtual address space used for SNAT. The route (on your peripheral components) will point to the serverside floating self IP of the BIG-IP.