Posts

Showing posts with the label syn attack

How to reduce SYN flooding using sysctl.conf

Linux has a nice file for setting up kernel value at boot time. This file can be found in   /etc/sysctl.conf   If you open and edit, you will find many values you can transform to improve security on your server. I think the most important value you can set to secure your TCP connection is:   net.ipv4.tcp_syncookies=1   Another thing you can do is reduce the timeout value from 60 to 30 seconds, this is not TCP standard at all to do that, but at least, the connection refresh will be faster than default. Note: keep in mind this reduces impact of SYN flooding, it will not stop them completely. Make sure you don’t set this value too low over wise it could create TCP loss packet situation.   net.netfilter.nf_conntrack_tcp_timeout_syn_recv=30 Last thing you can make is to create Iptables entry to limit them on your server. # create new chains iptables -N syn-flood # limits incoming packets iptables -A syn-flood -m limit --limit 10/second --limit-burst 50 -j RETURN #...

How to detect SYN attack

How to detect SYN attack? During a SYN attack, the attacker is opening lots of connections to you server but never completes the TCP connection establishment process. The state of each connection will stay SYN_RECV. This is how to count such connections: # netstat -anutp | grep SYN_RECV | wc -l If the number is >30, it is likely that you are under a SYN attack. However, I do not recommend to use netstat in automated scripts to monitor traffic. When you are under a real SYN attack, it may run too long and drain lots of CPU resources. 2) You can monitor live bandwidth of the attack using vnstat: # vnstat -l -i eth0 It is a very useful tool that will definitely help you understand how powerful the attack is. 3) I also recommend you to install an advanced analogue of top called htop and also monitor how the attack affects your CPU resources. Launch htop: # htop Press F2, go to 'Display options' and choose 'Display threads in a different color'. You will see system inte...

SYN flooding and DoS attack

It has become popular now days to receive incoming attack from foreign server, with the only goal to discard all access/connections to your server. Those attacks are generally call “DoS” or “Denial of Service” attack. SYN flood or SYN attack is a denial-of-service method affecting hosts that run TCP server processes. The attack takes advantage of the state retention TCP performs for some time after receiving a SYN segment to a port that has been put into the LISTEN state. The basic idea is to exploit this behavior by causing a host to retain enough state for bogus half-connections that there are no resources left to establish new legitimate connections (RFC4987). SYN flood is relatively hard to mitigate, and that's why very popular. Why? It often uses random source IPs which cannot be banned, as they are generated in each packet; It consumes little resources on the attacker side and lots of on the victim’s; The protection is quite complex, full of nuances and req...