diff --git a/README.md b/README.md index 9a77918..d3ff214 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,15 @@ scp -rO www root@ROUTER:/ ``` 6) Run `chmod +x /www/cgi-bin/limitator.json` 7) Run `opkg update && opkg install iptables-mod-extra coreutils-date` -8) Run `mkdir ~/limitator` -9) Run `crontab -e` and copy&paste contents in `crontab` file. -10) Run `/etc/init.d/limitator enable` -11) Reboot. +8) Run `opkg install iptables-mod-extra` +9) Run `opkg install coreutils-date` +10) Run `mkdir ~/limitator` +11) Run `crontab -e` and copy&paste contents in `crontab` file. +12) Run `/etc/init.d/limitator enable` +13) Reboot. + +### Additional steps for Backfire 10.03 +1) Change packages source in /etc/opkg.conf putting http://web.archive.org/web/20260213065024id_/ before the URL. For example: http://web.archive.org/web/20260213065024id_/https://archive.openwrt.org/backfire/10.03.1/brcm-2.4/packages +2) Install iptables-mod-ipopt (NO ESTOY SEGURO, SIN PONERLO FUNCIONA Y EN EL WRT54G DABA ERROR EL COMANDO IPTABLES CON EL MODULO QUOTA Y LO TENÍA INSTALADO) +3) Delete /bin/date link +4) Cannot scp files, you need to paste but vi messes with idents. Use `:set noai` command in vi. Other option is using wget from other routers (not an option for limitator.json). diff --git a/crontab b/crontab index 06773d9..db13234 100644 --- a/crontab +++ b/crontab @@ -5,8 +5,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin */10 7-23 * * * /etc/init.d/limitator save & # Restart at midnight 1 0 1-12,14-31 * * /etc/init.d/limitator restart & -# Reset the quota monthly -1 0 13 * * /etc/init.d/limitator reset & +# Reset the quota monthly (MUST BE START DAY!) +1 0 1 * * /etc/init.d/limitator reset & # Reboot at 4:30am every day # Note: To avoid infinite reboot loop, wait 70 seconds diff --git a/limitator b/limitator index 5cd5c47..f35afe8 100644 --- a/limitator +++ b/limitator @@ -13,9 +13,7 @@ EOF config_load "limitator" config_get MONTHLY_QUOTA limitator quota 120 # Monthly quota in GB config_get WAN_DEV limitator wan_dev 'wlan0' # Interface name for WAN -config_get FIRST_DAY limitator first_day 1 # Day of month when internet plan starts accounting.. -config_get START_TIME limitator start_time '00:00' # Starting time of internet plan limited hours. -config_get END_TIME limitator end_time '23:59' # Ending time of internet plan limited hours. +config_get FIRST_DAY limitator first_day 1 # Day of month when internet plan starts accounting. config_get INTRANET limitator intranet '10.0.0.0/8' # Traffic in Intranet does not count for quota. config_get EXCLUDE_NETWORK limitator exclude_network # Traffic originated in specified network does not count for quota. config_get EXCLUDE_NETWORK2 limitator exclude_network2 # Traffic originated in specified network does not count for quota. @@ -137,15 +135,11 @@ set_iptables_rule(){ iptables --wait -I $IPTABLES_CHAIN $(get_iptables_quota_rule_num) -c 0 $(get_saved_used_bytes) -m quota --quota $(get_remaining_quota) -j ACCEPT 2>> $LOG_FILE iptables --wait -I $IPTABLES_CHAIN $(($(get_iptables_quota_rule_num) + 1)) -j REJECT 2>> $LOG_FILE - # Iptables requires UTC time - local start_time_utc=$(date -u +%H:%M --date=@$(date -d "today $START_TIME" +%s)) - local end_time_utc=$(date -u +%H:%M --date=@$(date -d "today $END_TIME" +%s)) - iptables --wait -I $IPTABLES_FORWARD 1 -d $INTRANET -s $INTRANET -j ACCEPT - iptables -I $IPTABLES_FORWARD 2 -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN - iptables -I $IPTABLES_INPUT -i $WAN_DEV ! -s $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN - iptables -I $IPTABLES_OUTPUT -o $WAN_DEV ! -d $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN + iptables -I $IPTABLES_FORWARD 2 -j $IPTABLES_CHAIN + iptables -I $IPTABLES_INPUT -i $WAN_DEV ! -s $INTRANET -j $IPTABLES_CHAIN + iptables -I $IPTABLES_OUTPUT -o $WAN_DEV ! -d $INTRANET -j $IPTABLES_CHAIN } start() {