Forum Discussion
Ashu_Aggarwal
Sep 18, 2020Cirrus
Restrict access to VS by ip & time
I have to restrict access to a VS by IP & time. So during a particular window (time/day) only specific ip ranges should be allowed to access that vs. Can someone please guide how to do that on a LTM....
Nov 03, 2020
Hi Ashu,
Can you replace lines 20-24? (set denied values)
if { ($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end]) } {
set denied 1
}
else {
set denied 0
}
when RULE_INIT {
array set static::timerange {
Monday {}
Tuesday {}
Wednesday {}
Thursday {"03:15" "03:30"}
Friday {}
Saturday {}
Sunday {}
}
}
when HTTP_REQUEST {
if { not [class match [IP::client_addr] equals dg_allow_ip_during_deployment] } {
set now [clock seconds]
set current_day [clock format $now -format {%A}]
set start [lindex $static::timerange($current_day) 0]
set end [lindex $static::timerange($current_day) 1]
if { ($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end]) } {
set denied 1
} else {
set denied 0
}
unset start end
} else {
set denied 0
}
if { $denied } {
drop
}
}
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