I'm reading through the source code that writes directly to system iptables
in /system/xbin/iptables
in Android. I would like to do the same in Ubuntu without using the iptables
command.
Where is iptables
located on Ubuntu 16.04? I followed some questions and answers which don't apply on this version of Ubuntu.
find / -name iptables
return /sbin/iptables
which contains binary and maybe man!
Where is the file that the iptables
command writes its configuration?
Best Answer
iptables
stores its information in RAM, meaning it's non-persistent. If you want to save/restore it at will, you'll need to use a couple commands.First off, you would use
iptables
as normal to set up your rules the way you want them. Then, you can freeze these rules using something like:Then, to load your rules, it's a simple matter of running:
You can add this to your
/etc/rc.local
or similar to have it run automatically at boot, or you can have your program call this executable (or just pass the sameiptables
rules over and over again).