Forum Discussion

Moe_Jartin's avatar
Aug 25, 2009

using Switch to match IP address??

I need to SNAT a handful of servers to public addresses when they are sending mail so that their reverse records match when the receiving mail server does the lookup. The BigIP is inline, i.e. the BigIP is the gateway for the mail servers. I am trying to get the folowing iRule to work bu the GUI keeps saying "wrong number of args on line 3." Help. Is the IP address NOT seen as aa string? What am I missing?

 

 

when CLIENT_ACCEPTED {

 

if { [TCP::local_port] == 25 }{

 

switch -glob [string [IP::addr [IP::remote_addr]]] {

 

10.100.250.91 {

 

snatpool SNAT_mail1.mysite.org

 

}

 

10.100.250.92 {

 

snatpool SNAT_mail2.mysite.org

 

}

 

10.100.250.94 {

 

snatpool SNAT_mail4.mysite.org

 

}

 

10.100.250.93 {

 

snatpool SNAT_mail3.mysite.org

 

}

 

10.100.250.96 {

 

snatpool SNAT_mail3.mysite.org

 

}

 

}

 

}

 

}

1 Reply

  • you shouldn't need globbing for exact IP matching. Try this:

     
     when CLIENT_ACCEPTED { 
       if { [TCP::local_port] equals 25 } { 
         switch [IP::remote_addr] { 
           "10.100.250.91" { snatpool SNAT_mail1.mysite.org } 
           "10.100.250.92" { snatpool SNAT_mail2.mysite.org } 
           "10.100.250.94" { snatpool SNAT_mail4.mysite.org } 
           "10.100.250.93" - 
           "10.100.250.96"  { snatpool SNAT_mail3.mysite.org } 
           default { do something } 
         } 
       } 
     } 
     

    HTH...Jason