Scheduled forwarding rule vs. different timezones

I need to switch two port forwarding rules on and off by cron. I know that I could do it like this:

config redirect
	option extra '-m time --timestart 08:00:00 --timestop 10:00:00 --weekdays Mon'

But those times need to be given in UTC, while the server depending on this rule and its cron daemon is using local timezone. Changing the server's time zone would bring too many problems. So I need a way to synchronize the switching of this rule on my router and the cron job on my server, to be on the safe side when DST is applied.

The most easiest way I can think of would be a cron based swapping of two different files /etc/config/firewall, one in which those two rules are enabled and one in which they are disabled, and restarting the firewall after swap.

That will certainly work, but I'm sure OpenWRT provides a much more elegant way of doing this, doesn't it? :wink:

Thanks in advance for help and clues!

If your router and your server have the same local time, you could add option --kerneltz to your extra arguments.

FYI, firewall redirects support native UCI syntax for time restrictions including the start/stop and UTC time options:

1 Like

According to

that argument it doing nothing any more. ???

It works just fine, but better follow the vgaetera's suggestion.

1 Like

I'm sorry, but I do not understand your answer. :frowning:

Could you please explain a bit more verbose?

Take a better look at the options. You could add the following to your redirect rule:

        option start_time '08:00:00'
        option stop_time '10:00:00'
        option weekdays 'Mon'
        option utc_time '0'

1 Like

Oh! That looks very simple, that I understand. :slight_smile:

Thanks, I will try it at once!

YES!!! IT WORKS!!! :smiley:

Could you tell me, where you found this information, please?

Follow the link, provided by vgaetera and scroll down.

BTW it is his solution, so I'll change your mark.

1 Like

I saw the options in the table you and pavelgl are referring to, but I didn't realize that those parameters could be turned used in of code like pavelgl showed me.

I guess I still have a lot to learn about OpenWRT, especially about uci and its configuration. It's quite different from all versions of Linux I have been using until now.

Thanks again for your help (both of you) and your patience!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.