diff --git a/ddos-mitigator.sh b/ddos-mitigator.sh index 30599a4..6dd5d7b 100755 --- a/ddos-mitigator.sh +++ b/ddos-mitigator.sh @@ -471,9 +471,9 @@ banned="$(exec_as_root fail2ban-client get "${jail}" banip)" connections=$(ss -HOn state established "( sport = :${port} )" | tr -s '[:blank:]' | cut -d' ' -f5) # IPv6-mapped-IPv4: [::ffff:192.168.0.1]:443 -echo "${connections}" | grep '^\[::ffff:' - | cut -d: -f4 | cut -d] -f1 > "${fileraw}" +echo "${connections}" | grep '^\[::ffff:' - | cut -d: -f4 | cut -d] -f1 | grep -v '^$' > "${fileraw}" # Pure IPv4: 192.168.0.1:443 -echo "${connections}" | grep -v '^\[' - | cut -d: -f1 >> "${fileraw}" +echo "${connections}" | grep -v '^\[' - | cut -d: -f1 | grep -v '^$' >> "${fileraw}" # Group and sort the data into the subnet-specific files. sort "${fileraw}" > "${file32}"