Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debian 8 iptables-persistent

Tags:

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!

like image 746
Николай Булашев Avatar asked Jun 13 '15 12:06

Николай Булашев


People also ask

Are iptables persistent?

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.

Where are iptables stored Debian?

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.


1 Answers

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 : )

like image 78
tobuslieven Avatar answered Nov 06 '22 06:11

tobuslieven