Ilmarinen, ABATAPA
Протупил-с, извиняюсь
Уважаемые Господа! Помогите настроить Parental Control?
загрузил cutter (Огромное спасибо angel_il) отсюда- http://wl500g.info/showthread.php?t=...ghlight=cutter
Cron работает (настраивал по http://wl500g.info/showpost.php?p=20276&postcount=3) и пишет в тест лог-
Sun Jan 13 16:42:01 EST 2008
Sun Jan 13 16:45:03 EST 2008
Sun Jan 13 16:48:01 EST 2008
Sun Jan 13 16:50:55 EST 2008
Sun Jan 13 16:54:02 EST 2008...
Но теперь control-internet.sh почемутр не работает! Он у меня работает в XWRT.
Я пытаюсь настроить Parental Control чтоб вырубать интернет по часам на одном PC (192.168.1.55 например).
Вот скрипт, взял у XWRT-
запускаю из crontab строчками-Code:#!/bin/sh ########################################################### # Control access from the LAN to the Internet (WAN) # # This script must be adapted to your configuration to fit your needs # It can be used in a cron job or by the Webif^2 page Misc/Restrictions # # Usage: control-internet.sh [status|open|close|explain] # status Returns 0 if traffic is allowed to the Internet # open Open traffic to the Internet # close Block traffic to the Internet # explain Print info on stations blocked # # ########################################################### case "$1" in "status") status=$(/usr/sbin/iptables -nvL | grep "DROP" | grep "192.168.1.55") if [ "$status" = "" ]; then exit 0 else exit 1 fi ;; "explain") # Print information on blocked workstations echo "192.168.1.55 (archibald)" exit 0 ;; "open") # Drop all rules blocking Internet access /usr/sbin/iptables -D forwarding_rule -s 192.168.1.55 -j DROP 2> /dev/null /usr/sbin/iptables -D forwarding_rule -d 192.168.1.55 -j DROP 2> /dev/null exit 0 ;; "close") # Add iptables rules to block Internet traffic # If cutter package installed, then cut active connections # cutter: http://www.lowth.com/cutter/ if [ -x /opt/bin/cutter ]; then /opt/bin/cutter 192.168.1.55 2> /dev/null fi /usr/sbin/iptables -I forwarding_rule -s 192.168.1.55 -j DROP 2> /dev/null /usr/sbin/iptables -I forwarding_rule -d 192.168.1.55 -j DROP 2> /dev/null exit 0 ;; *) echo "Usage: $0 [status|open|close]" echo " status Status of bridge to the Internet (0 = open)" echo " open Open traffic to the Internet" echo " close Block traffic to the Internet" echo " explain Print information on blocked hosts" ;; esac
00 06 * * * admin /opt/etc/control-internet.sh open
00 22 * * * admin /opt/etc/control-internet.sh close
А как отладить?
А как проверить работу Cutter?
Ели запускаю из командной строки /opt/bin/cutter 192.168.1.55
то выдает-
Code:For connection 192.168.1.55:1561 -> 202.8.2.74:10299 sending RST from 202.8.2.74:10299 to 192.168.1.55:1561 ACK not seen so RST not sent (sorry!) sending RST from 173.53.92.103:1561 to 202.8.2.74:10299 ACK not seen so RST not sent (sorry!) For connection 192.168.1.55:1803 -> 68.144.68.173:6255 sending RST from 68.144.68.173:6255 to 192.168.1.55:1803 ACK not seen so RST not sent (sorry!) sending RST from 173.53.92.103:1803 to 68.144.68.173:6255 ACK not seen so RST not sent (sorry!)
Last edited by piezomotor; 14-01-2008 at 01:35.
Решил упростить и переделал по другому-
Создал папки в /opt/etc/
cron.internet-close
cron.internet-open
Добавил в crontab строки-
00 06 * * * admin run-parts /opt/etc/cron.internet-open
00 22 * * * admin run-parts /opt/etc/cron.internet-close
Поместил в cron.internet-open файл internet-open.sh
#!/bin/sh
# Open Internet pipe
/usr/sbin/iptables -D forwarding_rule -s 192.168.1.55 -j DROP -m state --state NEW,ESTABLISHED
/usr/sbin/iptables -D forwarding_rule -d 192.168.1.55 -j DROP -m state --state NEW,ESTABLISHED
Поместил в cron.internet-close файл internet-close.sh
#!/bin/sh
# Close Internet access
/usr/sbin/iptables -I forwarding_rule -s 192.168.1.55 -j DROP -m state --state NEW,ESTABLISHED
/usr/sbin/iptables -I forwarding_rule -d 192.168.1.55 -j DROP -m state --state NEW,ESTABLISHED
Все равно не заработало, не вырубает интернет на 192.168.1.55 в 22.00!
Где грабли?
А если еще более упростить то будет выглядеть так:
Прописывать в post-boot. Вместо всего того, про что выше говорится.Code:#!/bin/sh mkdir -p /var/spool/cron/crontabs /usr/sbin/crond echo '00 06 * * * /usr/sbin/iptables -D FORWARD -d 192.168.1.55 -j DROP 00 22 * * * /usr/sbin/iptables -I FORWARD -d 192.168.1.55 -j DROP ' | /usr/bin/crontab -
Еще проще, без крона, добавить правило:
Или еще проще через веб морду настроить LAN to WAN фильтр, что эквивалентно этому правилу, но помещенному в оптимальное место в таблице, а не в начало.Code:iptables -I FORWARD -m time --timestart 22:00:00 --timestop 06:00:00 --days Mon,Tue,Wed,Thu,Fri,Sun,Sat -s 192.168.1.55 -j DROP
Серф то оно блокирует. А вот те проги, что юзают постоянное подключение к серверу, например аську, не блокирует. А аська как известно великое мирское зло, которое мешает вовремя отлучится от компа Такчто, имхо, лучше правило ставить первым либо через крон вызывать утилиту типа cutter, о котрой говорилось выше. Она должна разрывать все установленные tcp сессии с указанным ip. Но это о5 же решение, для которого ограничиться настройками через веб-морду необойтись...
Спасибо
Я нашел этоу ссылку
http://www.wl500g.info/showpost.php?...1&postcount=24
Проверю...