Forum Discussion

tosneyp_93777's avatar
tosneyp_93777
Icon for Nimbostratus rankNimbostratus
Jun 24, 2011

Forwarding IP Irule

Hi,

 

 

I am currently testing a setup with our new Exchange 2010 infrastructure where by all SMTP traffic is sent to a VIP, which in turn then sends out the SMTP traffic to our smarthost...I've set everyhting up apart from being able to forward the smtp traffic that is received by the VIP toward the FQDN of the smarthost/exchange cluster - so I was wondering if anyone could assist me with this? I understand that this is probably a very simple request, but forgive me as I am a newbie to the F5 world....especially IRules! ;)

 

 

Many thanks for any help...

 

 

Cheers,

 

Pete

8 Replies

  • Jason replied here:

     

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/aff/25/afv/topic/aft/1179270/afc/1251283/Default.aspx

     

    Yes, that's possible. Check out the RESOLV::lookup command in the wiki: http://devcentral.f5.com/wiki/default.aspx/iRules/RESOLV__lookup.html

     

     

    Aaron
  • Hi,

     

     

    I was wondering if anyone tell me if the below rule will simply forward any traffic it receives toward cluster.messagelabs.com? I think it will use the dns server (172.1.1.1) to resolve the address cluster.messagelabs.com, but once it has resolved it, will it actually forward traffic toward cluster.messagelabs.com?

     

     

    *********************************************************************************************************************************************

     

     

    Select the first returned IP address as the destination IP (inherits the destination port from the client's destination port).

     

    when CLIENT_ACCEPTED {

     

    log local0. "cluster.messagelabs.com is currently at IP [RESOLV::lookup @172.1.1.1 "cluster.messagelabs.com"]"

     

     

    Get IP(s) for hostname cluster.messagelabs.com against 172.1.1.1 name server

     

    set ips [RESOLV::lookup @172.1.1.1 -a "cluster3out.eu.messagelabs.com"]

     

     

    Log result. If there are multiple IP's it could be a TCL list like {1.1.1.1 2.2.2.2 3.3.3.3}.

     

    log local0. "Looked up cluster3out.eu.messagelabs.com and found $ips, parsed first element: [lindex $ips 0]"

     

     

    Check if the first list element was empty

     

    if {$ips eq ""}{

     

     

    Select the IP

     

    node [lindex $ips 0]

     

    }

     

    }

     

     

    *********************************************************************************************************************************************

     

     

    Sorry if this is a numpty question, but I'm new to this! :(

     

     

    May thanks,

     

    Pete
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    That looks pretty close. Make sure you have a port on your node command, but other than that, it should work, assuming you can always resolve the host address.

     

     

    Funny, I don't think I've seen anyone do that before. You're basically creating a dynamic DNS setup for the back-end server(s) with your LTM. Interesting. :)

     

     

    Colin
  • never seen it before eh....well i am special! ;) lol

     

     

    Thank you for the response Colin, nice to know its close! :) I dont suppose you know how i could make it select a node from a pool that I have created do you? The current setup is ok, but if one/that node goes down then my mail wouldnt be routed out! :(

     

    Pete
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    How would you select what pool to direct it to? I suppose if you have a list of the resolved IP -> pool mapping stored somewhere within the iRule (a Data Group most likely) you could do a lookup with RESOLV::lookup to find the IP of the host, then check that IP against the Data Group and determine which pool to send it to based on that.

     

     

    I.E. If the IP is 10.10.10.1-6 go to poola, if 192.168.7.5-17 poolb, etc.

     

     

    Does that sound like what you're looking for?

     

     

    Colin
  • erm, well I only have one pool that I want to use....and 3 nodes in that pool... its not a case of selecting a pool, more selecting a node/load balancing the traffic to the nodes! :)
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    So you want to choose a particular node out of the pool, without allowing the pool to do the actual load balancing? What is it you want to do to select the node out of the pool? Some kind of static mapping or a metric or...what?

     

     

    This is definitely doable it's just a matter of figuring out the specific logic you want to apply.

     

     

    I.E. "If a request comes in from subnet A, always send it to member A unless it's down, in which case send it to member B", that kind of thing.

     

     

    Colin