Linux – debian 8 iptables-persistent

debianiptableslinuxservice

i have VPS Debian 8 jessie x64 stable release. After installation im trying to configure iptables (like in debian 7).

apt-get install iptables-persistent

executed succesefully, some packets were installed. but when im trying

service iptables-persistent start

im getting an error that says thar service iptables-persistent unrecognized

halp!

Best Solution

Persist IP Tables Debian/Ubuntu

To persist any changes you make to your iptables rules, do the following.

Install iptables-persistent:

sudo apt-get install -y iptables-persistent

Make any changes you want to your iptables rules, eg

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

Then run

sudo dpkg-reconfigure -y iptables-persistent

The rules should persist after a reboot now.

Extra Info

The dpkg-reconfigure just causes iptables-persistent to do again what it does at install, which is to save the current iptables into a file using a command just like:

iptables-save >/etc/iptables/rules.v4
ip6tables-save >/etc/iptables/rules.v6

The iptables-persistent package causes the os to run something like the following on reboot.

iptables-restore < /etc/iptables/rules.v4
ip6tables-restore < /etc/iptables/rules.v6

Hope this helps : )

Related Question