Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  56] [ 0]  / answers: 1 / hits: 100747  / 3 Years ago, wed, june 16, 2021, 7:27:23

Is there a "best practice" or standard to make a few iptables rules permanent? I mean: automatically applied upon a system reboot?



I am using a VPS with Ubuntu Server 10.04 LTS (Lucid Lynx).



Thank you.



BIG EDIT: I don't want ANY rule to be persisted (like iptables-persistent package does). I want only my own specific set to be reloaded... if other rules are eventually added by running iptables, these should be discarded...


More From » server

 Answers
2

The simplest method is to use
iptables-save and
iptables-restore to
save the currently-defined iptables rules to a file and (re)load them
(e.g., upon reboot).



So, for instance, you would run



sudo iptables-save | sudo tee /etc/iptables.conf


to save your current iptables rules to /etc/iptables.conf and then insert these lines in /etc/rc.local:



# Load iptables rules from this file
iptables-restore < /etc/iptables.conf

[#42980] Wednesday, June 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mocipe

Total Points: 161
Total Questions: 106
Total Answers: 118

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
;