LinuxQuestions.org
Visit Jeremy's Blog.
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 05-28-2015, 04:21 AM   #1
darksmiley
Member
 
Registered: Jan 2004
Location: London, England
Distribution: Usually Linux Mint, Debian, Ubuntu or CentOS
Posts: 234

Rep: Reputation: 30
Being DDoS'd. Can I cap connections?


Hi. We think we're getting repeatedly DDoS'd.

I run Ubuntu 12.04 on my server.

Is there any way to completely limit all connections, so that a DDoS cannot bring down the surrounding network and then hopefully I can allow through my own connection for maintenance?

I know that this means my websites would go down, but at least I'd still have access and a degree of control and wouldn't jeopardise my hosting.

I read that I could do this with my http server - lighttpd - but I was wondering if Linux can do this holistically?

Thanks!
 
Old 05-28-2015, 07:51 AM   #2
tombelcher7
Member
 
Registered: Feb 2008
Location: Surrey
Distribution: Debian
Posts: 214

Rep: Reputation: 5
I am by no means an expert and would encourage others to comment but the first thing I thought off was conntrack and found this article for Redhat which may be relevant:

http://rhelblog.redhat.com/2014/04/1...-linux-7-beta/
 
Old 05-28-2015, 08:49 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
I have asked the mod for this sub-forum to move your thread to the security sub-forum.
In the meantime, please have a look at this information: http://www.linuxquestions.org/questi...61/#post222579
 
Old 05-29-2015, 10:10 AM   #4
Amarildo
Member
 
Registered: Jun 2014
Posts: 176

Rep: Reputation: Disabled
My firewall rules are set so nobody can ping me:

Code:
iptables -N In_RULE_1
iptables -A INPUT -p icmp  -m icmp  --icmp-type any  -j In_RULE_1
iptables -A In_RULE_1  -j LOG  --log-level info --log-prefix "RULE 1 -- DENY "
iptables -A In_RULE_1  -j DROP
I also have an anti-spoof rule:

Code:
iptables -N In_RULE_0
iptables -A INPUT -i your_network_card   -s your_host_name  -j In_RULE_0
iptables -A In_RULE_0  -j LOG  --log-level info --log-prefix "RULE 0 -- DENY "
iptables -A In_RULE_0  -j DROP
In my case:
Code:
iptables -N In_RULE_0
iptables -A INPUT -i enp0s7   -s amarildo   -j In_RULE_0
iptables -A In_RULE_0  -j LOG  --log-level info --log-prefix "RULE 0 -- DENY "
iptables -A In_RULE_0  -j DROP
Also, a rule to block invalid packets:

Code:
iptables -N drop_invalid
iptables -A OUTPUT   -m state --state INVALID  -j drop_invalid
iptables -A INPUT    -m state --state INVALID  -j drop_invalid
iptables -A INPUT -p tcp -m tcp --sport 1:65535 --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j drop_invalid
iptables -A drop_invalid -j LOG --log-level debug --log-prefix "INVALID state -- DENY "
iptables -A drop_invalid -j DROP
Also a no-Whois rule:

Code:
iptables -N In_RULE_2
iptables -A INPUT -p tcp -m tcp  --dport 43  -j In_RULE_2
iptables -A In_RULE_2  -j LOG  --log-level info --log-prefix "RULE 2 -- DENY "
iptables -A In_RULE_2  -j DROP
And a no-xmas-scan rule
Code:
iptables -N In_RULE_4
iptables -A INPUT -p tcp -m tcp   --tcp-flags ALL URG,ACK,PSH,RST,SYN,FIN  -j In_RULE_4
iptables -A In_RULE_4  -j LOG  --log-level info --log-prefix "RULE 4 -- DENY "
iptables -A In_RULE_4  -j DROP
Protection against IP fragments too:
Code:
iptables -N In_RULE_5
iptables -A INPUT -p all  -f   -j In_RULE_5
iptables -A In_RULE_5  -j LOG  --log-level info --log-prefix "RULE 5 -- DENY "
iptables -A In_RULE_5  -j DROP
No tracerout either:
Code:
iptables -N In_RULE_7
iptables -A INPUT -p udp -m udp  --dport 33434:33524  -j In_RULE_7
iptables -A In_RULE_7  -j LOG  --log-level info --log-prefix "RULE 7 -- DENY "
iptables -A In_RULE_7  -j DROP
And no "who" too:
Code:
iptables -N In_RULE_6
iptables -A INPUT -p udp -m udp  --dport 513  -j In_RULE_6
iptables -A In_RULE_6  -j LOG  --log-level info --log-prefix "RULE 6 -- DENY "
iptables -A In_RULE_6  -j DROP
If you're interested in my rules http://pastebin.com/UsufFHFk
 
1 members found this post helpful.
Old 05-29-2015, 04:44 PM   #5
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by darksmiley View Post
Hi. We think we're getting repeatedly DDoS'd.
Why do you think that? Perhaps as relevant, if you have captured some packets, then maybe there are some characteristics of the packets that are useful in filtering out the bad stuff from the good stuff. Feel free to obfuscate any of your own addresses before posting anything.

Quote:
Originally Posted by darksmiley View Post
Is there any way to completely limit all connections, so that a DDoS cannot bring down the surrounding network and then hopefully I can allow through my own connection for maintenance?
Well, if for example, all of the DDOS packets are on one port and you have SSH on another port, you could drop all of the packets coming in some port/range of ports, and allow through the packets on the SSH port. Probably won't work perfectly, but may work well enough.

Quote:
Originally Posted by darksmiley View Post
I know that this means my websites would go down, but at least I'd still have access and a degree of control and wouldn't jeopardise my hosting.
Websites will probably be intermittently accessible, but that may be better than where you are now. A lot depends on whether there are bottlenecks upstream that are limitations.

Quote:
Originally Posted by darksmiley View Post

I read that I could do this with my http server - lighttpd - but I was wondering if Linux can do this holistically?
I don't know what you mean by 'holistically', but the further upstream you do this, the less unnecessary processing you do before dropping stuff, the less chance that you run out of processing power to deal with the packets.

Oh, and you can rate limit almost anything in iptables. The difficulty is doing it without doing more harm than good...

Last edited by salasi; 05-29-2015 at 04:46 PM. Reason: added 'rate limiting'
 
Old 06-04-2015, 01:54 PM   #6
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
Personally, I prefer using the DDOS protection from APF firewall. This will dynamically defend against such attacks. Also, it is a free download.

Advanced Policy Firewall
https://www.rfxn.com/projects/advanced-policy-firewall/

How To Install And Configure Advanced Policy Firewall
https://www.howtoforge.com/how-to-in...-on-centos-5.3

I am not finding a good tutorial on the DDOS section, so unfortunately I must say "Read The Manual". The DDOS section is fairly simple though.
 
Old 06-06-2015, 05:20 AM   #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
Quote:
Originally Posted by salasi View Post
Why do you think that?
Valid question!


Quote:
Originally Posted by darksmiley View Post
Is there any way to completely limit all connections, so that a DDoS cannot bring down the surrounding network and then hopefully I can allow through my own connection for maintenance?
Limiting connections can be done using iptables modules but DoS and DDoS measures should be applied upstream. Please see common SANS and other DoS / DDoS mitigation documentation.
 
  


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
LXer: World Live DDoS attack maps – Live DDoS Monitoring LXer Syndicated Linux News 0 08-09-2014 08:30 PM
How to cap bandwidth/speed? yitzle Linux - Software 4 01-04-2008 11:56 AM
Socks cap substitute waqaskool Linux - Software 0 06-04-2007 03:12 AM
c++ memory cap ashirazi Programming 18 04-25-2005 03:07 PM
Resolution cap? Weapon Linux - Newbie 2 01-26-2002 12:35 AM

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

All times are GMT -5. The time now is 06:37 AM.

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