Startseite » firewall

Tag: firewall

Iptabels add blocklist while systemctl start

add iptables with binarydefense.com blocklist

Edit systemd iptables.service

[Unit]
Description=IPv4 Packet Filtering Framework
Before=network-pre.target
Wants=network-pre.target

[Service]
Type=oneshot
ExecStart=/usr/bin/iptables-restore /etc/iptables/iptables.rules
ExecStartPost=/etc/script/ipban.list.sh
ExecReload=/usr/bin/iptables-restore /etc/iptables/iptables.rules
ExecStop=/usr/lib/systemd/scripts/iptables-flush
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

The iptables script contains

you should modify as you need -I or -A and ‘input’ chain

#!/bin/sh
for i in `curl https://www.binarydefense.com/banlist.txt`; do
iptables -A INPUT -s $i -j DROP
done