View previous topic :: View next topic |
Author |
Message |
shira Tux's lil' helper

Joined: 27 Aug 2002 Posts: 122
|
Posted: Thu Oct 16, 2003 12:16 pm Post subject: preventing a DoS |
|
|
my server has been DoSed twice in the last week and I can't afford this kind of downtime
I looked at iptraf during one of these and I didn't see any large ammounts of packets moving
iptraf did not log a lot of icmp movement and all the movement on the other protocols was me shelled in
could you all offer me some advice on how to
a. prevent this kind of thing using iptables or some other software like this
b. find the doofus whos doing this
I would really appreciate any help you can give, I really don't need to null route my server again to keep it from getting hammered |
|
Back to top |
|
 |
shira Tux's lil' helper

Joined: 27 Aug 2002 Posts: 122
|
Posted: Thu Oct 16, 2003 8:19 pm Post subject: |
|
|
any recommendations of stuff to block or kernel options to change? |
|
Back to top |
|
 |
meowsqueak Veteran


Joined: 26 Aug 2003 Posts: 1549 Location: New Zealand
|
Posted: Thu Oct 16, 2003 8:41 pm Post subject: |
|
|
If you configure your firewall to ignore ICMP (ping) requests it makes it invisible to ping. This can fool some subnet scans into thinking you don't exist. It isn't hard to work around, but it can stop a lot of clueless script kiddies from targetting you. It's a start. |
|
Back to top |
|
 |
ozonator Guru


Joined: 11 Jun 2003 Posts: 591 Location: Ontario, Canada
|
Posted: Thu Oct 16, 2003 9:30 pm Post subject: |
|
|
For protection against a SYN flood kind of DoS attack, iptables might help. There are 'limit' options for matching packets, which can be used to limit the rate at which packets will match a rule. You'll need to have support for the 'limit' match in your netfilter kernel config; check for Networking options -> IP: Netfilter configuration -> limit match support.
As an example, this might do the trick for reducing the effectiveness of a typical SYN flood:
Code: | iptables -N serve
iptables -F serve
iptables -A INPUT -p tcp --syn -m limit --limit 1/s -j serve |
In this 'serve' table, you can then put rules to deal with legitimate incoming TCP services that you want to allow, and drop the rest, e.g.
Code: | iptables -A serve -p tcp --dport 22 -j ACCEPT
<other rules for incoming services here>
#if you want to log:
iptables -A serve -m limit --limit 4/minute --limit-burst 5 -j LOG --log-prefix "BLOCKED CONNECTION ATTEMPT "
iptables -A serve -j DROP |
Of course, you can use a different name for the table (I picked 'serve', since it's for externally available services), as well as adjust the limit and limit-burst options to your own preference (man iptables for an explanation of how these parameters work). I just chose some reasonable values; what will be efficient in your situation is up to you.
The suggestion to block pings seems reasonable, too; on the other hand, I've always thought it was good firewalling practice to allow ICMP types 0, 3, and 11. Maybe you could limit the rate for those, too:
Code: | iptables -A INPUT -i $EXTIF -p icmp --icmp-type 0 -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -i $EXTIF -p icmp --icmp-type 3 -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -i $EXTIF -p icmp --icmp-type 11 -m limit --limit 1/s -j ACCEPT |
Again, the rate you want to allow these packets is up to you. Don't know if this will do everything you need, or even anything you need, but it might give you some ideas of where you might start trying, depending on the kind of DoS you're experiencing. |
|
Back to top |
|
 |
devon l33t

Joined: 23 Jun 2003 Posts: 943
|
Posted: Thu Oct 16, 2003 10:36 pm Post subject: |
|
|
How did you log onto your server during the DoS attack? Console or some admin-network? Are you sure you were the target and not collateral damage?
If the badguy has a lot of bandwidth, all he/she has to do is saturate your link. I have seen >100Mbps attacks and know others have seen larger. Did you contact your network provider during the attacks? Or are you the network provider? Do you do any Netflow/sFlow sampling? |
|
Back to top |
|
 |
shira Tux's lil' helper

Joined: 27 Aug 2002 Posts: 122
|
Posted: Fri Oct 24, 2003 1:08 am Post subject: |
|
|
well I implemented a firewall that uses that syn code and the icmp code but it still wasn't too successful
I've learned that the person attacking us is using infected hosts to do his/her dirty work so ipbanning and such is not an option
is there anything else that I can do to block other types of attacks?
I logged into my server using very slow ssh
we are the target
we contacted the isp during the attack and had our ip null routed
I do not know what netflow/sflow is |
|
Back to top |
|
 |
sschlueter Guru

Joined: 26 Jul 2002 Posts: 578 Location: Dortmund, Germany
|
Posted: Fri Oct 24, 2003 1:25 pm Post subject: Re: preventing a DoS |
|
|
shira wrote: | my server has been DoSed twice in the last week and I can't afford this kind of downtime |
How do you know it's been a DoS?
shira wrote: | could you all offer me some advice on how to
a. prevent this kind of thing using iptables or some other software like this
|
Well, since you haven't described what you have experienced, I can't help. |
|
Back to top |
|
 |
sschlueter Guru

Joined: 26 Jul 2002 Posts: 578 Location: Dortmund, Germany
|
Posted: Fri Oct 24, 2003 1:28 pm Post subject: |
|
|
ozonator wrote: | For protection against a SYN flood kind of DoS attack, iptables might help. There are 'limit' options for matching packets, which can be used to limit the rate at which packets will match a rule. |
This is not a real solution to the syn flood attack. Activating syn cookies in the kernel is a real solution. |
|
Back to top |
|
 |
jaalex n00b


Joined: 22 Oct 2003 Posts: 39
|
Posted: Fri Oct 24, 2003 1:51 pm Post subject: Monmotha IPTables Scrip |
|
|
I use the Monmotha iptables firewall script. It has a lot of neat rate limiting features. Along with the right kernel patches you can stop almost any DoS that doesn't fill your network pipe.
You can get the monmotha script by doing
Jason _________________ No Matter Where You Go, There You Are |
|
Back to top |
|
 |
shira Tux's lil' helper

Joined: 27 Aug 2002 Posts: 122
|
Posted: Fri Oct 24, 2003 2:39 pm Post subject: |
|
|
is there any way to prevent the pipe filling attacks
I'm pretty sure that's what we're getting hit with
we don't have direct access to the router so it'd difficult to null route our selves when we're attacked |
|
Back to top |
|
 |
jaalex n00b


Joined: 22 Oct 2003 Posts: 39
|
Posted: Fri Oct 24, 2003 5:43 pm Post subject: Upstream DOS Attack |
|
|
IF your getting hit with an attack from upstream that consumed all the bandwidth on your link from your ISP the only way to stop that is to have the ISP block the traffic. Depending on your SLA and contract with the ISP they might or might not be willing to do this.
Jason _________________ No Matter Where You Go, There You Are |
|
Back to top |
|
 |
sschlueter Guru

Joined: 26 Jul 2002 Posts: 578 Location: Dortmund, Germany
|
Posted: Fri Oct 24, 2003 5:52 pm Post subject: |
|
|
shira wrote: | is there any way to prevent the pipe filling attacks
I'm pretty sure that's what we're getting hit with
|
Now I'm confused. In your original post you said "I looked at iptraf during one of these and I didn't see any large ammounts of packets moving".
If you don't tell us what kind of problem you experience, we can't help you. |
|
Back to top |
|
 |
shira Tux's lil' helper

Joined: 27 Aug 2002 Posts: 122
|
Posted: Fri Oct 24, 2003 7:53 pm Post subject: |
|
|
ya, I didn't see a bunch of traffic in iptraf and yet our line got saturated at 10mbps |
|
Back to top |
|
 |
fimblo Guru

Joined: 19 Feb 2003 Posts: 306 Location: European Union, Stockholm
|
Posted: Fri Oct 24, 2003 9:21 pm Post subject: Re: Upstream DOS Attack |
|
|
jaalex wrote: | IF your getting hit with an attack from upstream that consumed all the bandwidth on your link from your ISP the only way to stop that is to have the ISP block the traffic. Depending on your SLA and contract with the ISP they might or might not be willing to do this.
Jason |
...which results in the most effective DoS, i.e. a zeroed route in the isp's routing table.
I work at a national ISP in Sweden and theres not much a single host can do about a "real" DoS, or a DDoS. you can set up the most complex iptables rules, but if the packet isnt stopped before it hits your kernel, your system will go down even if you have a good iptalbe rul (because of the sheer volume of packets coming in per second).
This is a real problem which not only end users and companies are scratching their heads about, the ISPs are also quite helpless (like I said above, we can stop all traffic to a specific ip, but this stops even legit traffic... which in effect is a DoS) if the source of the attack is outside of their AS.
anywhoo. If you could log in to your system via ssh the attack wasnt very severe. sometimes we see gigabit attacks on some poor victim ip. (of course he doesnt get the full brunt of the attack, our routers do, but the chances of a legit packet arriving is like... well, epsilon).
 _________________ http://blahonga.yanson.org - little geekblog
http://blahona.yanson.org/howtos/livecd - yet another livecd howto |
|
Back to top |
|
 |
|