0

I am new here and I hope find answer to my question i hvae set rule in openwrt iptables

iptables -A FORWARD -s 192.168.2.14 -m time --timestart 8:00 --timestop 18:30 -j ACCEPT

iptables -A FORWARD -s 192.168.2.14 -j DROP

this rules not worked but when i have changed to this one it worked

iptables -A forwarding_rule -s 192.168.2.14 -m time --timestart 8:00 --timestop 18:30 -j ACCEPT

iptables -A forwarding_rule -s 192.168.2.14 -j DROP

can any one explain to me the wrong i have done

1 Answers1

1

In OpenWRT you have in default 3 rules:

(you can see this in iptables -nvL FORWARD

  • rule 1 to move chain to FORWARDING_RULE
  • rule 2 accept ESTABLISHED/RELATED packets
  • rule 3 REJECT ALL OTHER FORWARD RULE

And Policy about FORWARD is DROP.

When you add:

iptables -A FORWARD .....

Then this is in the end, after reject. When you add this:

iptables -A forwarding_rule ...

you add this rule to forwarding_rule chain (in default this chain is empty).

If you would like add to FORWARD you must add this rule before rule number 3 in example:

iptables -I FORWARD 1 ...
# or
iptables -I FORWARD 2 ...
# or
iptables -I FORWARD 3 ...
iptables -I [chain_name] [number] ...

then would be works :)

-A add after existing rules, -I add before existing rules

sorry for my bad english... :(

liske1
  • 114
  • 4