Drop existing TCP/UDP when time-of-day restriction activates

Suggest improvements and new features for Gargoyle.

Moderator: Moderators

Post Reply
qtr
Posts: 17
Joined: Fri Apr 29, 2011 7:34 am

Drop existing TCP/UDP when time-of-day restriction activates

Post by qtr »

Hi,
I would like to know if it's possible to have this feature in a future release. Basically dropping all existing TCP/UDP connections as soon as time-of-day Firewall>Restriction becomes enforcing for the particular IPs. Thanks

User avatar
powerlogy
Posts: 66
Joined: Wed Aug 22, 2012 12:04 pm
Location: Turkey

Re: Drop existing TCP/UDP when time-of-day restriction activ

Post by powerlogy »

Make a firewall script and execute it with cron.

qtr
Posts: 17
Joined: Fri Apr 29, 2011 7:34 am

Re: Drop existing TCP/UDP when time-of-day restriction activ

Post by qtr »

Appreciate your suggestion, powerlogy. But how do you implement it on a WNDR3700 v1 router running Gagoyle v1.5.10?

User avatar
powerlogy
Posts: 66
Joined: Wed Aug 22, 2012 12:04 pm
Location: Turkey

Re: Drop existing TCP/UDP when time-of-day restriction activ

Post by powerlogy »

in /etc/config/firewall, add this line end of the file

Code: Select all

config include 
option path '/etc/firewall.custom'
create a new file at /etc/firewall.custom , add any value at first line and save.

Code: Select all

example
create a new file at /etc/init.d/firewall.custom , add this lines

Code: Select all

#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2010 OpenWrt.org

START=45
restart() {
echo 'iptables --flush' > /etc/firewall.custom
echo 'iptables -P INPUT DROP' >> /etc/firewall.custom
echo 'iptables -P FORWARD DROP' >>> /etc/firewall.custom
echo 'iptables -P OUTPUT DROP' >>>> /etc/firewall.custom
/etc/init.d/firewall reload
}
stop() {
echo '' > /etc/firewall.custom
echo '' >> /etc/firewall.custom
/etc/init.d/firewall reload
}
and make a cron jon about it at /etc/crontabs/root
execute at 22:00, everyday and drop connections.

Code: Select all

0 22 * * * /etc/init.d/firewall.custom restart
execute at 09:00, allow all connections

Code: Select all

0 9 * * * /etc/init.d/firewall.custom stop
i didn't tested it yet.I made some fixes.

qtr
Posts: 17
Joined: Fri Apr 29, 2011 7:34 am

Re: Drop existing TCP/UDP when time-of-day restriction activ

Post by qtr »

powerlogy, it might do the trick but looks like it drops all the connections instead of those from certain PCs being time restricted. However, I get the idea. Thanks.

Post Reply