Forum Discussion
Casa_Henry_1360
Nimbostratus
Feb 26, 2009Snat for mail servers
I am new to Irules and TCL. I have a need to create SNATs for my mail servers. What I am looking for is the syntax for parsing a field. So if I have a series of addresses defined as hosts
class hosts {
192.168.16.112 198.212.10.112
192.168.16.108 198.212.10.108
}
I would like to inspect it and if the address is the 1st field then the SNAT will be the second field.
Any help would be greatly appreciated.
- hoolio
Cirrostratus
You can use the findclass (Click here) command to return the matching field. The first example on the wiki page is pretty close to what you're trying to do. - Deb_Allen_18Historic F5 Accounthmmm, I'm gonna go out on a limb here & suggest an iRule is not the answer here. Unless you need the iRule to do something else, I'd just create one-to-one SNATs in the GUI instead & enable them on the server vlan...
- Casa_Henry_1360
Nimbostratus
I agree, except that because of some other configuration issues that wont work for me. Basically I will be using forwarding servers to my firewall. The concern is that there would be leakage using the 1 to 1 SNATS - Deb_Allen_18Historic F5 AccountWhether you use a simple iRule as mentioned in your original post to map the origin to the SNAT addr, or define 1-1 SNATs, the end result (src addr of the egress packet based on src addr of ingress packet) will be the same.
The direction is outbound from the servers, so the server in this case is the client, and remote_addr is the server address. Because it's a wildcard virtual server, local_addr is the endpoint destination address. So in this comparison you would replace the 192.168 addr with the subnet your servers that should be SNAT'd is on.when CLIENT_ACCEPTED { if {[IP::addr [IP::local_addr] equals 192.168.1.0/24] }{ set snat_addr [findclass [IP::remote_addr] $::hosts " "] if {!($snat_addr eq "") }{ snat $snat_addr } } }
- Deb_Allen_18Historic F5 AccountThe direction is outbound from the servers, so the server in this case is the client, and remote_addr is the server address. Because it's a wildcard virtual server, local_addr is the endpoint destination address. So in this comparison you would replace the 192.168 addr with the subnet your servers that should be SNAT'd is on.
- Casa_Henry_1360
Nimbostratus
Thanks for the help so far. I dont want to nat everything on that network, just specific hosts. I found the "findclass" example and was going to use that. So I have - Ian_SmithRet. EmployeeIt sounds like you need to get your mail servers to send mail from addresses that match your published MX records but maybe don't want them to use those IPs for other (perhapse internal) traffic.
when CLIENT_ACCEPTED { switch [ IP::client_addr ] { 10.10.1.1 { snat 172.16.1.1 } 10.10.1.2 { snat 172.16.1.2 } default { snat automap } } }
when CLIENT_ACCEPTED { if [ [TCP::local_port] == 25 ] { switch [ IP::client_addr ] { 10.10.1.1 { snat 172.16.1.1 } 10.10.1.2 { snat 172.16.1.2 } default { forward } } } else { forward } }
- Deb_Allen_18Historic F5 Accountcasaman:
- Casa_Henry_1360
Nimbostratus
Again, I apologize for my naivete. Here is the situation. I have the need to have 2 separate networks, lets say 192.168.16 and 192.168.246. Because of PCI compliance these 2 networks cannot speak directly together but all requests need to go to the firewall then back to big ip. Simply creating 1 to 1 snats may cause big ip to respond to the request without it going to the firewall. However I still have the need for outgoing mail to have a natted external address The use of an iRule was the recommended course by F5 support. - Casa_Henry_1360
Nimbostratus
I also tried the ismith suggestion using the following:
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