Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 01-13-2021, 07:14 AM   #1
Registered: Oct 2012
Posts: 536

Rep: Reputation: Disabled
iptables and ipset lists

How do I create ipset lists before iptables is restored on machine start up? Right now, when I start up my server, iptables rules fail to load because the ipset lists do not exist that are referred to in iptables rules.
Old 01-14-2021, 01:30 AM   #2
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,510
Blog Entries: 11

Rep: Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472Reputation: 3472
Your question answers itself... "create ipset lists before iptables is restored".

The ipset sets must exist before any rules which reference them can be added, as you are aware. They can be empty and populated later, but they must exist. So as you want to do this at boot time arrange your init system to run your ipset create scripts before loading the iptables rules. How that is done is distro specific and subject to much variation/customization.

To get more specific help on how you may do that you should at least provide a better description including your distro, how your iptables rules are initialized, how your ipsets are created and populated, etc.
1 members found this post helpful.
Old Today, 03:41 AM   #3
LQ Newbie
Registered: Nov 2019
Posts: 8

Rep: Reputation: Disabled
Try a script with something like this:
ipset create some_ipset_to_drop hash:net
for i in $(cat /path/on/a/disk/to/someiplist.file ); do ipset -A some_ipset_to_drop $i; done
/sbin/iptables-restore < /path/on/a/disk/to/firewall_rules.file
File with addresses to block is required. Or create empty sets to populate later.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't execute otherwise working script at startup for ipset and iptables with systemd chrisknight Linux - Security 9 02-17-2019 05:19 PM
[SOLVED] iptables/ipset configuration with hashlimit/limit not behaving properly freeindy Linux - Security 1 03-06-2014 07:29 AM
[SOLVED] ipset and iptables - recompile iptables? Habitual Linux - Server 2 02-19-2014 09:12 AM
iptables / ipset, redirect a set to another host/ip? i5050net Linux - Networking 1 09-16-2013 02:06 PM
LXer: Unique Sorting Of Lists And Lists Of Lists With Perl For Linux Or Unix LXer Syndicated Linux News 0 09-05-2008 02:50 PM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration