2

I have this rule to control my macs addresses and work fine:

Note: $mac is a variable that contains the macs addresses of my local network, so iptables rule goes inside a "for; do done"

iptables -A INPUT -s 192.168.1.0/24 -i eth1 -m mac --mac-source $mac -p tcp --dport 80 -m time --timestart 08:00:00 --timestop 18:00:00 --weekdays Mon,Tue,Wed,Thu,Fri -j ACCEPT

However, the rule stops working, if I change the schedule in reverse. That is, it starts at 6:00 PM and ends at 8:00 AM the next day

iptables -A INPUT -s 192.168.1.0/24 -i eth1 -m mac --mac-source $mac -p tcp --dport 80 -m time --timestart 18:00:00 --timestop 08:00:00 --weekdays Mon,Tue,Wed,Thu,Fri -j ACCEPT

Why does this happen?. Thanks in advance

1 Answer 1

1

You can try to use 2 iptables rules like those:

iptables -A INPUT -s 192.168.1.0/24 -i eth1 -m mac --mac-source $mac -p tcp --dport 80 -m time --timestart 18:00:00 --timestop 23:59:59 --weekdays Mon,Tue,Wed,Thu,Fri -j ACCEPT

iptables -A INPUT -s 192.168.1.0/24 -i eth1 -m mac --mac-source $mac -p tcp --dport 80 -m time --timestart 00:00:00 --timestop 08:00:00 --weekdays Mon,Tue,Wed,Thu,Fri -j ACCEPT
1
  • 1
    When we set --timestart or --timestop, iptable uses only time in format HH:MM:SS without date YYYY-MM-DD. It does not count next day. And on my opinion, if this rule could work, it would difficult manage it.
    – SergiyL
    May 22, 2018 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .