Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  24] [ 0]  / answers: 1 / hits: 55654  / 2 Years ago, wed, august 31, 2022, 10:32:33

Every time I reboot I loose the iptables rules that took me so looong to enter. I know I can save them and restore them on boot, but is there anyway to save them forever? Do I really need to restore them on boot every time? Seriously?



The problem is I have a HUGE list of IPs in which I use a while loop to load them in. This can take upwards of 10 minutes.



This is my home FTP server. It's a small vm with 1gb ram and very little processing power. There are so many IPs because I've pretty much given up on the Asian continent. I don't need them to be hitting up my FTP server everyday with brute force. I also block gov. monitors, trackers and spammers.



This is the while loop I use to load in the list.



grep INPUT block.list | while read LISTA; do sudo iptables -A $LISTA; done

More From » iptables

 Answers
4

First, create a file with the contents of iptables-save:



sudo iptables-save > /etc/iptables_rules


It doesn't really matter where you put the file, all you have to do is make sure that the next line refers to the same file. Next, open /etc/rc.local and add this line:



/sbin/iptables-restore < /etc/iptables_rules


From now on, every time your computer powers up or restarts iptables will load rules from the file that you specified.


[#39584] Thursday, September 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
piscen

Total Points: 134
Total Questions: 117
Total Answers: 133

Location: Indonesia
Member since Wed, Jul 7, 2021
3 Years ago
;