I add this rule:
sudo iptables -t nat -A OUTPUT -d a.b.c.d -p tcp \ --dport 1723 -j DNAT --to-destination a.b.c.d:10000
- When restart computer rules are deleted. Why?
- What I can do to make the rules persist?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
On Debian, install
sudo apt-get install iptables-persistent
The package will automatically load
/etc/iptables/rules for you during boot.
Any time you modify your rules, run
/sbin/iptables-save > /etc/iptables/rules to save them. You can also add that to the shutdown sequence if you like.
There is no option in iptables which will make your rules permanent. But you can use
iptables-restore to fulfill your task.
First add the iptable rule using the command you gave.
Then save iptables rules to some file like
/etc/iptables.conf using following command:
$ iptables-save > /etc/iptables.conf
Add the following command in
/etc/rc.local to reload the rules in every reboot.
$ iptables-restore < /etc/iptables.conf