[Solved] Iptables rules with firewall disabled

I have a TP Link router with ExtRoot enabled and the router connects to the main gateway through WiFi using relay configuration and the router does not use the firewall because it is disabled. If I enable the firewall i cannot access the device from the network.

Now I wanted to monitor users as to how much internet they use during the day so I found this article on Openwrt forum and it said to use the iptables but on reboot the iptables get clear. I also installed the luci statistics package to save the stats to USB stick.

The problem that i am facing now is:

  1. I cannot save the iptables rules and when the router reboots all the rules get cleared.
  2. If i put the iptables commands in the rc.local file to start them once at boot the luci-app-statistics does not record any activity in the firewall section. But it does record the activity if i run those commands after the router has booted up or if I restart the luci stats tool/rrdtool.

Any pointers here?

Based on that, it may be some kind of race condition between the iptables rules and collectd (the statistics daemon).

But it sounds a bit confusing that running those commands later would enable stats logging. That could suggest that there is something wrong with /etc/rc.local or that the iptables gets still clearled after /etc/rc.local has been run. Do the rules get added to iptables ok at boot? does "iptables -L -v" show them?

You might try adding a command in /etc/rc.local to restart collectd after you have added the iptables rules:
/etc/init.d/collectd restart

After restarting the device, rules do get added every time. I checked the output of iptables -L -v and the rules are there. As you said about restarting collectd, it did not help. So I restarted the luci-statistics and voila it started working. Thanks

Have you enabled luci-statistics? So that it starts at boot?

In practice, luci-statistics just generates config for collectd and restarts collectd.

Based on your symptoms, it might be that luci-statistics is not enabled, and thus collectd does not get proper config at boot. (Manually restarting luci-statistics forces the new collectd config and starts collectd)

/etc/init.d/luci-statistics enable

Restarting luci_statistics after adding the rules does help to store the stats and track them. So my issue has been resolved. Thank you