last day (15 days later) » 

23:57
1
A: OpenWRT: iptables rules will be deleted automatically

amccormackOpenWRT There are a few ways to edit iptables in OpenWRT. Direct use of iptables OpenWRT will run the contents of /etc/firewall.user at startup. It is a shell script, so it'll look something like this: root@OpenWrt:/etc# cat firewall.user # This file is interpreted as shell script. # Put yo...

thanks @amccormack but I use disto is openwrt
thanks amccormack I did like you said but when I reboot I find that the rules is deleted. and i change eth0 with eth0.2.
did you put your rules in there? I just put some sample rules in there to show where they go. I'll add a note about testing.
@ amccormack I have a project that is application is to add rules from the table in the filter web interface so I created a script that allows you to add rules in the filter table like this: try:os.system ("iptables -D INPUT -m mac-source --mac" + mac + "j DROP") except Exception as e: print e os.system ("iptables INPUT -m mac-source --mac" + mac + "j DROP") I did not add the rules manually.
As long as you are using os.system, why not use it twice. Also run a os.system("echo iptables -D INPUT -m mac-source --mac" + mac + "j DROP") >> /etc/firewall.user. Also, beware of the blatant command injection risk in your os.system usage, be sure whitelist good characters.
I tried adding a rule in /etc/firewall.user then did ping from the pc to mac so I can do ping. # This file is interpreted as shell script. # Put your custom iptables rules here, they will # be executed with each firewall (re-)start. iptables -A INPUT -m mac --mac-source 18:CF:5E:FE:F8:61 -j DROP ~ ~ ~ ~ ~
23:57
And what happened? For the purpose of your question, it doesn't so much matter if your rule worked (because it could be an error with your rule), but it matters more that the rule was present in iptables -L after a reboot.
yes my aim is that the rule in this table iptbales -L but I can not find it after startup. that's why I made the test "to ping" to determine whether the rule at this /etc/firewall.user execute or non.@amccormack
I would use a test that is less complicated. Try touch /tmp/test
ok I did like you said and i did stop firewall and start and the file is not execute
Well the file should just be created. You would probably need to do a full restart. I don't know if restarting the firewall service is enough.
no the file is not created
23:57
Which version of OpenWRT are you using?
rampis, openwrt-na9xx-r25875-20121204
It could be that the openwrt version is old and that the /etc/firewall.user file is not being executed.
If that is the case, try using /etc/rc.local and add your command to that file

last day (15 days later) »