I'm trying to work out why this keeps crashing my server. Weirdly, the server stays up - but nothing can be reached (FTP, Apache, nginx, emails etc). The script is:
#!/bin/bash
ipset -q flush maltrailoutgoing
ipset -q create maltrailoutgoing hash:net
for ip in $(curl http://127.0.0.1:8338/fail2ban 2>/dev/null | grep -P '^[0-9.]+$'); do ipset add maltrailoutgoing $ip; done
iptables -I OUTPUT -m set --match-set maltrailoutgoing src -j DROP
ALL of these run fine when I do it manually - but as soon as I try and run it as manually as:
bash /root/block-spammers.sh
The terminal locks up, and then kicks me off SFTP , browsers etc.
This command just returns stuff like:
123.123.123.1234
234.234.234.234
i.e one IP per line
Can anyone see why this would fail? I'm baffled as to why it keeps killing my server :/
OS: Ubuntu 18.04
UPDATE: As suggested, I have added an ACCEPT rule, to bypass our own IP:
iptables -A INPUT -s 213.168.249.115 -j ACCEPT
I'm not sure why that would help, but it seems to (I can't see our server IP, 192.0.0.x or my own IP in the list, so pretty sure its not blocking me)