diff --git a/limitator b/limitator index 765fab1..f21106c 100644 --- a/limitator +++ b/limitator @@ -18,6 +18,7 @@ config_get INTRANET limitator intranet '10.0.0.0/8' # Traffic in Intranet does n 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. config_get EXCLUDE_NETWORK3 limitator exclude_network3 # Traffic originated in specified network does not count for quota. +config_get EXCLUDE_NETWORK4 limitator exclude_network4 # Traffic originated in specified network does not count for quota. config_get USED_BYTES_FILE limitator used_bytes_file '/root/limitator/used_bytes' # A persistent file to save used bytes value. config_get LOG_FILE limitator log_file '/root/limitator/log' # A persistent file to log. config_get IPTABLES_CHAIN limitator iptables_chain 'LIMITATOR' # Name of iptables chain. @@ -39,7 +40,11 @@ get_iptables_quota_rule_num(){ if [ -n "$EXCLUDE_NETWORK" ];then if [ -n "$EXCLUDE_NETWORK2" ];then if [ -n "$EXCLUDE_NETWORK3" ];then - echo -n 7 + if [ -n "$EXCLUDE_NETWORK4" ];then + echo -n 9 + else + echo -n 7 + fi else echo -n 5 fi @@ -137,6 +142,10 @@ set_iptables_rule(){ iptables --wait -I $IPTABLES_CHAIN 5 -s $EXCLUDE_NETWORK3 -j ACCEPT iptables --wait -I $IPTABLES_CHAIN 6 -d $EXCLUDE_NETWORK3 -j ACCEPT fi + if [ -n "$EXCLUDE_NETWORK4" ];then + iptables --wait -I $IPTABLES_CHAIN 7 -s $EXCLUDE_NETWORK4 -j ACCEPT + iptables --wait -I $IPTABLES_CHAIN 8 -d $EXCLUDE_NETWORK4 -j ACCEPT + fi 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