Right now netstat lists 200 - 4000 connections to the same IP in India. Seems like some kind of flooding attack to me.
e.g:
tcp 0 0 [removed] 182.65.238.[removed].in-:mysql TIME_WAIT
I've tried to kill current connection with this command but this didn't work
iptables -t filter -I INPUT 1 -p tcp -m tcp -s 182.65.238.[] -j DROP
tcpkill -i any -9 host 182.65.238.[removed]
I've added the IP to ufw and even ban it with fail2ban but I cannot get rid of the open connections.
Two Questions:
- how to kill/close all tcp connections from this IP
- any chance of logging this kind of pattern in order do ban it with a fail2ban jail or set up some iptable chain limitions like for "regular" dos attacks?
systeminfo:
- ubuntu 20.04
- nginx
- ufw
- fail2ban
- syn cookies enabled
- maybe relevant: additional ufw rules I'm using
# Enter rule
-A ufw-before-input -p tcp --dport 80 -j ufw-http
-A ufw-before-input -p tcp --dport 443 -j ufw-http
Limit connections per Class C
-A ufw-http -p tcp --syn -m connlimit --connlimit-above 50 --connlimit-mask 24 -j ufw-http-logdrop
Limit connections per IP
-A ufw-http -m state --state NEW -m recent --name conn_per_ip --set
-A ufw-http -m state --state NEW -m recent --name conn_per_ip --update --seconds 10 --hitcount 20 -j ufw-http-logdrop
Limit packets per IP
-A ufw-http -m recent --name pack_per_ip --set
-A ufw-http -m recent --name pack_per_ip --update --seconds 1 --hitcount 20 -j ufw-http-logdrop
fail2banthe first option – djdomi Aug 09 '22 at 18:54ss -nptto your question, which shows the processes related to these connections. If they are not visible inss, that is another indicator of a compromised system. Please also clarify where did you obtain the first example in your question, what tool etc. – Tero Kilkanen Aug 09 '22 at 20:28netstat -anpfor my first output.ss -nptdoes not show theses connections. The Remote Host Ip is listet on 4 Blacklists by the way. Can you explain the syntax of 182.65.238.[removed].in-:mysql what does the .in- mean? I couldn't find anything in the manpage or google... – jan Aug 09 '22 at 21:07.inis the top-level domain of India, which means that the IP address is most likely located in India. – Tero Kilkanen Aug 10 '22 at 17:14