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!
That is because iptables rules, by default, will not persist after a reboot. After configuring your system's iptables rules, there is one more important step thay you must do in order to make sure the rules are still there after a reboot.
There is a service called “iptables”. This must be enabled. The rules are saved in the file /etc/sysconfig/iptables for IPv4 and in the file /etc/sysconfig/ip6tables for IPv6.
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 : )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With