孩子天天看pad怎么办,买一个阿里儿童路由器吗?功能太多,太复杂,太费钱。
20行搞定限定时长功能,路由器系统依托于Openwrt系统开发。
脚本文件:
#!/bin/ash
unallow()
{
echo "noallow $1 access internet"
iptables -t raw -D PREROUTING -s $1 -j DROP
iptables -t raw -A PREROUTING -s $1 -j DROP
}
allow()
{
echo "allow $1 access internet"
iptables -t raw -D PREROUTING -s $1 -j DROP
}
if [ $1 == "allow" ]
then
allow $2
else
unallow $2
fi
crontab如下:
30 12 * * * sh /root/allow.sh allow 192.168.10.100
30 13 * * * sh /root/allow.sh unallow 192.168.10.100
30 19 * * * sh /root/allow.sh allow 192.168.10.100
30 20 * * * sh /root/allow.sh unallow 192.168.10.100
30 21 * * * sh /root/allow.sh allow 192.168.10.100
30 22 * * * sh /root/allow.sh unallow 192.168.10.100