LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-22-2012, 01:22 PM   #1
mkools
LQ Newbie
 
Registered: Oct 2004
Posts: 15

Rep: Reputation: 0
SYN attack or not? How to block?


Hi,

My servers have been victim of what I think is a Syn flood attack. All my servers have gigabit connections but at one moment I saw about 2 - 3 mB/s coming in and the entire server became unresponsive. I couldn't even SSH anymore into the server and even typing through KVM didn't work.

My firewall logs showed a lot of IP addresses which are probably all spoofed?

Now, I've been trying to block these attacks by using various iptables scripts found with Google, but none of them seem to work and I don't even know if it's really a syn flood attack. I have syncookies enabled in the kernel, I tried running floodmon but all without success.

Anybody know how to deal with these type of attacks? Thanks!


The source and destination ports are always the same, 1234 to 80, I replaced my IP btw with a fake one:

Code:
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=2.87.234.198 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9746 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=145.98.200.80 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9751 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=14.202.208.44 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9747 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=26.142.87.38 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9748 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=20.159.193.26 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9754 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=9.106.175.182 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9753 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=173.157.70.81 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9757 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=160.51.58.163 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9765 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=103.13.234.19 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9755 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=212.214.144.103 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9766 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=211.177.191.118 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9759 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=102.93.173.240 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9758 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=149.44.220.53 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9761 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=1.14.136.208 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9767 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=131.234.35.54 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9763 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=178.114.6.120 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9760 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=117.18.37.221 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9769 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=215.94.28.180 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9788 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=145.248.128.14 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9768 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=107.22.203.159 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9762 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=99.175.168.112 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9770 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=203.26.42.88 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9787 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=61.79.30.78 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9790 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=177.28.93.62 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9764 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=149.152.35.122 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9792 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=99.32.154.75 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9771 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=205.189.184.205 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9789 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=124.84.53.117 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9791 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=69.16.62.133 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9794 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=94.167.155.70 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9796 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=182.77.205.199 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9800 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=45.27.101.85 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9797 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=70.133.120.149 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9793 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=57.53.37.160 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9799 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=83.189.170.232 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9795 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=65.41.200.144 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9802 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=201.178.78.47 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9809 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
Sep 21 22:29:58 ams01 kernel: IN_LEFTOVERS IN=eth1 OUT= MAC=00:25:90:51:68:f4:00:12:f2:c1:3a:00:08:00 SRC=1.78.189.3 DST=213.247.0.0 LEN=40 TOS=0x00 PREC=0x00 TTL=244 ID=9804 PROTO=TCP SPT=1234 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0
 
Old 09-22-2012, 02:10 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Well it's go the SYN flag... If you insert these two rules and in this order:
Code:
iptables -t raw -I PREROUTING 1 -m tcp -p tcp --sport 1234 --dport 80 -j DROP
iptables -t raw -I PREROUTING 1 -m tcp -p tcp --sport 1234 --dport 80 -j NOTRACK
that should take care of any TCP traffic with source port 1234 and destination port 80 for now. You should however block invalid traffic and limit traffic some more. Regardling the latter I just posted some iptables rules here (do adapt to ports in use) and apparently my remark about not using any kludges seemed right on the mark... Also please be aware there's only so much an end point can manage: do discuss with your provider.
 
2 members found this post helpful.
Old 09-22-2012, 02:35 PM   #3
mkools
LQ Newbie
 
Registered: Oct 2004
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Well it's go the SYN flag... If you insert these two rules and in this order:
Code:
iptables -t raw -I PREROUTING 1 -m tcp -p tcp --sport 1234 --dport 80 -j DROP
iptables -t raw -I PREROUTING 1 -m tcp -p tcp --sport 1234 --dport 80 -j NOTRACK
that should take care of any TCP traffic with source port 1234 and destination port 80 for now. You should however block invalid traffic and limit traffic some more. Regardling the latter I just posted some iptables rules here (do adapt to ports in use) and apparently my remark about not using any kludges seemed right on the mark... Also please be aware there's only so much an end point can manage: do discuss with your provider.
Thanks for this! I'll add the rule see if it works. The thing is, these servers run game servers and only use UDP (except for SSH). I am blocking all traffic except for the UDP game server ports, so how come an attack on port 80 is still working? Is it because connection tracking is overloading the machine? In that case can I just change your rule to apply it to all ports except 22? (or some other port I run SSH on).
 
Old 09-22-2012, 02:58 PM   #4
OlRoy
Member
 
Registered: Dec 2002
Posts: 306

Rep: Reputation: 86
You're right it's a SYN flood. Different IPs sending tons of SYNs per second, that also have the same TTL and same source port, and the IPID field is slowly increasing. It's certainly possible it's a single host flooding rather than many zombies. This one could be pretty easy to stop using the filter unspawn has given you. Unfortunately, it is likely also easy for the attacker to change source ports so you'd have to create a new rule.
 
Old 09-22-2012, 04:58 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by mkools View Post
so how come an attack on port 80 is still working? Is it because connection tracking is overloading the machine?
I don't like speculating or guessing so you best post your rule set as in 'iptables-save > /some/file.txt' then post the contents between [code]vBB code tags[/code] or attach as plain text file.
 
Old 09-23-2012, 12:00 PM   #6
mkools
LQ Newbie
 
Registered: Oct 2004
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
I don't like speculating or guessing so you best post your rule set as in 'iptables-save > /some/file.txt' then post the contents between [code]vBB code tags[/code] or attach as plain text file.
Thanks for your help I really appreciate it! Here's my output:

Code:
# Generated by iptables-save v1.4.7 on Sun Sep 23 18:56:51 2012
*raw
:PREROUTING ACCEPT [201945564:180966096462]
:OUTPUT ACCEPT [38746979:25310771882]
-A PREROUTING -p tcp -m tcp --sport 1234 --dport 80 -j NOTRACK
-A PREROUTING -p tcp -m tcp --sport 1234 --dport 80 -j DROP
COMMIT
# Completed on Sun Sep 23 18:56:51 2012
# Generated by iptables-save v1.4.7 on Sun Sep 23 18:56:51 2012
*filter
:INPUT DROP [28374:2225410]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:syn_flood - [0:0]
-A INPUT -s 204.188.252.0/24 -p tcp -m state --state NEW -m tcp --dport 27015 -j ACCEPT
-A INPUT -s 84.26.143.0/32 -p tcp -m state --state NEW -m tcp --dport 27015 -j ACCEPT
-A INPUT -s 213.247.35.0/24 -p tcp -m state --state NEW -m tcp --dport 27015 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn_flood
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 27015 -j ACCEPT
-A INPUT -s 213.247.35.0/24 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -s 216.185.114.0/24 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -s 204.188.252.0/24 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 27015 -m limit --limit 1/min --limit-burst 1 -j LOG --log-prefix "SRCDS-RCON "
-A INPUT -p tcp -m tcp --dport 27015 -j DROP
-A INPUT -p udp -m udp --dport 27015 -m length --length 0:32 -m limit --limit 1/min --limit-burst 1 -j LOG --log-prefix "SRCDS-XSQUERY " --log-ip-options
-A INPUT -p udp -m udp --dport 27015 -m length --length 0:32 -j DROP
-A INPUT -p udp -m udp --dport 27015 -m length --length 2521:65535 -m limit --limit 1/min --limit-burst 1 -j LOG --log-prefix "SRCDS-XLFRAG " --log-ip-options
-A INPUT -p udp -m udp --dport 27015 -m length --length 2521:65535 -j DROP
-A INPUT -p udp -m state --state NEW -m hashlimit --hashlimit-upto 1/sec --hashlimit-burst 3 --hashlimit-mode srcip --hashlimit-name StopDoS -j ACCEPT
-A INPUT -p udp -m limit --limit 1/min --limit-burst 1 -j LOG --log-prefix "UDP-SPAM " --log-ip-options
-A INPUT -p udp -j DROP
-A INPUT -j LOG --log-prefix "IN_LEFTOVERS "
-A OUTPUT -j ACCEPT
-A syn_flood -m limit --limit 1/sec --limit-burst 3 -j RETURN
-A syn_flood -j DROP
COMMIT
# Completed on Sun Sep 23 18:56:51 2012
 
Old 09-23-2012, 01:32 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Indeed odd since you have a filter table INPUT chain DROP policy. I have no explanation for it.

*BTW since your focus is on HLDS / UDP/27015, maybe this rule order is more efficient:
Code:
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -m udp -p udp --dport 27015 -m length --length 0:32 -j DROP
-A PREROUTING -m udp -p udp --dport 27015 -m length --length 2521:65535 -j DROP
-A PREROUTING -m tcp -p tcp --sport 1234 --dport 80 -j NOTRACK
COMMIT
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -m conntrack --ctstate NEW -m udp -p udp --dport 27015 -j ACCEPT
-A INPUT -m conntrack --ctstate NEW -m tcp -p tcp --dport 27015 -j TRUSTED_1
-A TRUSTED_1 -s 84.26.143.0/32 -j ACCEPT
-A TRUSTED_1 -s 204.188.252.0/24 -j ACCEPT
-A TRUSTED_1 -s 213.247.35.0/24 -j ACCEPT
-A TRUSTED_1 -j RETURN
-A INPUT -m conntrack --ctstate NEW -m tcp -p tcp --dport 3306 -j TRUSTED_2
-A TRUSTED_2 -s 204.188.252.0/24 -j ACCEPT
-A TRUSTED_2 -s 213.247.35.0/24 -j ACCEPT
-A TRUSTED_2 -s 216.185.114.0/24 -j ACCEPT
-A TRUSTED_2 -j RETURN
-A INPUT -m conntrack --ctstate NEW -m tcp -p tcp --dport 22 -j TRUSTED_3
-A TRUSTED_3 -j ACCEPT # This chain should only allow trusted ranges just like in the MySQL and HDLS chains.
-A TRUSTED_3 -j RETURN
-A INPUT -j LOG --log-prefix "IN_LEFTOVERS "
-A INPUT -j DROP
-A OUTPUT -j ACCEPT
COMMIT
If you want to try it save the rule set as /etc/sysconfig/iptables.new and then:
Code:
# Ensure old rule set is current and save a copy
/sbin/iptables-save > /etc/sysconfig/iptables | tee /etc/sysconfig/iptables.sav
# Change to new rule set and activate
/sbin/service iptables stop
cat /etc/sysconfig/iptables.new > /etc/sysconfig/iptables
/sbin/service iptables start
# Run some tests
sleep 15m
# Restore and activate previous rule set 
/sbin/service iptables stop
cat /etc/sysconfig/iptables.sav > /etc/sysconfig/iptables
/sbin/service iptables start || /sbin/service iptables stop
**There's quicker ways to do this but I'm trying to avoid any "IPTABLES_SAVE_ON.*="yes" options in /etc/sysconfig/iptables-config and if it doesn't work at least try to ensure you can get back in over SSH.
 
Old 09-23-2012, 03:26 PM   #8
OlRoy
Member
 
Registered: Dec 2002
Posts: 306

Rep: Reputation: 86
Code:
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn_flood
-A syn_flood -m limit --limit 1/sec --limit-burst 3 -j RETURN
-A syn_flood -j DROP
Please correct me if I'm wrong, but it seems like the above is a global rule limiting every new TCP connection to 1/sec with a burst of 3. If that's right, during a SYN flood, that could explain why you weren't able to connect to your server using SSH. When you say the server became unresponsive, I'm not sure if you're referring to just being able to connect to the SSH service, or the entire server.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i want protect my server from syn attack Dr.TrYaG Linux - Server 8 06-23-2011 12:04 PM
SYN Attack z_haseeb Linux - Security 7 06-30-2008 06:04 PM
symptoms of syn attack yawe_frek Linux - Security 4 10-15-2007 06:13 PM
What are all these SYN-FLOODs? Am I under attack? Vanyel Linux - Security 11 10-10-2007 04:35 PM
Syn Flood Attack Detect synaptical Linux - Security 2 07-25-2004 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration