Здравствуйте.
Где-то видел, но не могу найти. Как выглядит правило с указанием времени?
Например, время работы правила с 09:00 до 18:00.
Или, если такое бывает и время и дни недели.
Спасибо.
General syntax:
iptables RULE -m time --timestart TIME --timestop TIME --days DAYS -j ACTION
Where,
–timestart TIME : Time start value . Format is 00:00-23:59 (24 hours format)
–timestop TIME : Time stop value.
–days DAYS : Match only if today is one of the given days. (format: Mon,Tue,Wed,Thu,Fri,Sat,Sun ; default everyday)
An example:
Suppose you would like to allow incoming ssh access only available from Monday to Friday between 9 AM to 6. Then you need to use iptables as follows:
Input rule:
iptables -A INPUT -p tcp -s 0/0 --sport 513:65535 -d 202.54.1.20 --dport 22 -m state --state NEW,ESTABLISHED -m time --timestart 09:00 --timestop 18:00 --days Mon,Tue,Wed,Thu,Fri -j ACCEPT
Output rule:
iptables -A OUTPUT -p tcp -s 202.54.1.20 --sport 22 -d 0/0 --dport 513:65535 -m state --state ESTABLISHED -m time --timestart 09:00 --timestop 18:00 --days Mon,Tue,Wed,Thu,Fri -j ACCEPT
Но, насколько я помню, не все версии ядра поддерживают эту функцию, надо что-то ставить отдельно...