Saturday, June 25, 2016

Kiểm tra ip đang truy cập vào server bằng netstat

Kiểm tra ip đang truy cập vào server bằng netstat
Kiểm tra ip đang truy cập vào server bằng netstat

netstat -na | grep 80 | sort
netstat -n -p|grep SYN_REC | wc -l
netstat -n -p | grep SYN_REC | sort -u
netstat -na | grep 80 | sort
netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1


How to reject it
#Once you get an idea of the ip attacking your server, you can easily block it.
#Fire the following command to block that ip or any other specific ip:
route add ipaddress reject
#Once you block a paricular IP on the server, you can even crosscheck if the IP is blocked or not
#by using the following command:
route -n |grep IPaddress
#You can also block a IP with iptables on the server by using the following command.
iptables -A INPUT 1 -s IPADRESS -j DROP/REJECT
service iptables restart
service iptables save


EmoticonEmoticon