Skip to content

Commit

Permalink
Remove unused firewall-cmd commands and create ipsets using ipset com…
Browse files Browse the repository at this point in the history
…mand
  • Loading branch information
stephdl committed Mar 19, 2024
1 parent 97968c4 commit 9852021
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
exec 1>&2 # Send any output to stderr, to not alter the action response protocol

echo "Remove ipset firewall rules"
firewall-cmd --permanent --delete-ipset=crowdsec6-blacklists
firewall-cmd --permanent --delete-ipset=crowdsec-blacklists
#firewall-cmd --permanent --delete-ipset=crowdsec6-blacklists
#firewall-cmd --permanent --delete-ipset=crowdsec-blacklists
firewall-cmd --permanent --zone=public --remove-rich-rule='rule family="ipv4" source ipset="crowdsec-blacklists" drop'
firewall-cmd --permanent --zone=public --remove-rich-rule='rule family="ipv6" source ipset="crowdsec6-blacklists" drop'
# remove our systemd unit override fragment
Expand Down
14 changes: 8 additions & 6 deletions imageroot/bin/firewall-rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

action=$1
if [[ $action == 'create-ipset' ]]; then
if [[ ! -f /etc/firewalld/ipsets/crowdsec-blacklists.xml ]]; then
firewall-cmd --permanent --new-ipset=crowdsec-blacklists --type=hash:ip --option="timeout=0" --option="maxelem=150000"
#if [[ ! -f /etc/firewalld/ipsets/crowdsec-blacklists.xml ]]; then
#firewall-cmd --permanent --new-ipset=crowdsec-blacklists --type=hash:ip --option="timeout=0" --option="maxelem=150000"
ipset create crowdsec-blacklists hash:ip timeout 0 maxelem 150000
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source ipset="crowdsec-blacklists" drop'
fi
if [[ ! -f /etc/firewalld/ipsets/crowdsec6-blacklists.xml ]]; then
firewall-cmd --permanent --new-ipset=crowdsec6-blacklists --option=family=inet6 --type=hash:ip --option="timeout=0" --option="maxelem=150000"
#fi
#if [[ ! -f /etc/firewalld/ipsets/crowdsec6-blacklists.xml ]]; then
#firewall-cmd --permanent --new-ipset=crowdsec6-blacklists --option=family=inet6 --type=hash:ip --option="timeout=0" --option="maxelem=150000"
ipset create crowdsec-blacklists6 hash:ip family inet6 timeout 0 maxelem 150000
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv6" source ipset="crowdsec6-blacklists" drop'
fi
#fi
firewall-cmd --reload
fi
# elif [[ $action == 'add-rule' ]]; then
Expand Down

0 comments on commit 9852021

Please sign in to comment.