I have been testing my script to copy fail2ban log files to Proxmox firewall and have managed to make it work... one time
This works but it requires that there is an IPSET rule named XXX at the bottom of cluster.fw file.
If IPSET rules would work with [IPSET $(date -I)] we could just add this script to cron using @daily /root/bin/banned2.proxmox.sh.
Code:
cat /root/bin/banned2proxmox.sh
#!/bin/bash
#
# Sync fail2ban log files from client servers
rsync -a root@vm1.ic4.eu:/var/log/fail2ban.log /root/bin/fail2ban-vm1.log
rsync -a root@vm2.ic4.eu:/var/log/fail2ban.log /root/bin/fail2ban-vm2.log
# Clean up the logs and only show IP addressess
zgrep -h "Ban " /root/bin/fail2* | awk '{print $NF}' | sort | sort -n -r | tail -100 > /root/bin/banned.txt
# Only show uniq IP's and copy it to the end of cluster.fw
## Using date as IPSET name does not work... yet.
## echo "[IPSET $(date -I)]" >> /etc/pve/firewall/cluster.fw
# In the mean while make sure you have IPSET rule named XXX at the bottom of cluster.fw file
# It should look like this [IPSET XXX]
sort /root/bin/banned.txt | uniq -u >> /etc/pve/firewall/cluster.fw
This works but it requires that there is an IPSET rule named XXX at the bottom of cluster.fw file.
If IPSET rules would work with [IPSET $(date -I)] we could just add this script to cron using @daily /root/bin/banned2.proxmox.sh.
Last edited: