For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Andrew_Lagomar1's avatar
Andrew_Lagomar1
Icon for Nimbostratus rankNimbostratus
Apr 13, 2017

GTM DNS Time based iRule assistance needed

I am looking to create a GTM iRule where we can route away from Data Center 1 from 1AM - 2AM (maintenance) and from Data Center 2 from 2AM - 3AM (maintenance). I have created a wide IP and included some test pools using LTM VIPs in both centers. I have been following a few of the time based iRule discussion threads, but most of them were in reference to LTM "HTTP_REQUEST" which won't work on GTM as far as I know.

 

I am unsure which time variables I can set within the "when DNS_REQUEST" and which I may need to set outside the DNS_REQUEST logic. I am fairly new to iRules, but just looking for some help. Thanks!!

 

4 Replies

  • Hi, maybe you could do something like this:

    GTM rule for wide ip:

    when DNS_REQUEST {
        set now [clock format [clock seconds] -format "%H:%M"]
         Maintenance on DC 1
        if { $now >= "01:00" and $now < "02:00" } {
            VS DC 2
            host 10.10.10.10 
    
         Maintenance on DC 2
        } elseif { $now >= "02:00" and $now < "03:00" } {
            VS DC 1
            host 20.20.20.20 
        }
        Otherwise, resolve from pool
    }
    

    DC 1 VS:

    when HTTP_REQUEST {
        set now [clock format [clock seconds] -format "%H:%M"]
        if { $now >= "01:00" and $now < "02:00" } {
            HTTP::respond 200 content {MaintenanceSorry!} noserver
        }
    }
    

    DC 2 VS:

    when HTTP_REQUEST {
        set now [clock format [clock seconds] -format "%H:%M"]
        if { $now >= "02:00" and $now < "03:00" } {
            HTTP::respond 200 content {MaintenanceSorry!} noserver
        }
    }
    

    Regards.

  • Follow up question.....this seems to be working except for the fact that the two data centers are in different time zones. Is there a way to change the time to GMT so both centers register the same time period?

     

  • Hi,

    when products are deployed in multiple timezones, I configure the same timezone for both (like GMT)

    you can also try with command:

    set now [clock format [clock seconds] -format "%H:%M" -timezone GMT]
    
  • I think this is the solution:

    set now [clock format [clock seconds] -format "%H:%M" -gtm 1]

    So, in this way, it will ignore time zone on each location by using GTM 0.