Link to home
Start Free TrialLog in
Avatar of valleytech
valleytechFlag for United States of America

asked on

iptables to prevent ddos

dear, all
my server's being under heavily attacked. my server's OS: linux whitebox with iptables, apache2.0
i've configed my kernel with appropriate parameters to prenvet SYN flood as well as dDos. My Iptables is also written with this: to drop stealth scans
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
-A INPUT -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,RST FIN,RST -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,ACK FIN -j DROP
-A INPUT -p tcp -m tcp --tcp-flags ACK,URG URG -j DROP
-A INPUT -p tcp -m tcp --tcp-flags PSH,ACK PSH -j DROP

I added this rule in order to prevent the attacks from that IP address
-A INPUT -s 220.231.65.27 -p tcp -m tcp -m limit --limit 50/sec --limit-burst 150 -j REJECT --reject-with icmp-port-unreachable

However, most of my web's vistors used dial up internet, one IPs = thousands of visitors, so that the rule is not a good solution.

The attacker send out a bunch of request with POST (apache2, www.myweb.com/server-status shows this) to a URL.
is there anyway by iptables for my to block certain accesses from a MAC address.
or is therey any solutions by iptables for this kind of attacks

thanks alot alot
Avatar of ahoffmann
ahoffmann
Flag of Germany image

> .. block certain accesses from a MAC address.
only if these client are located in the same physical and logical subnet (not switched!), I doubt that this is the case ..

> ..  one IPs = thousands of visitors,
do you say that this IP is used for DDoS? then it might be a wice decission to block that IP at all :-))
Hi,

I would suggest using mod_dosevasive which is available from http://www.nuclearelephant.com/projects/dosevasive/
to help proect your server
Avatar of valleytech

ASKER

then..is there any way to limit access to certain pages within an interval of time?
how about iptables?....is there anyway to preven thise? ...i've heard that hardware solution will be the best for this kind of problem
i've been using mod-evasive also . . . but it's not an appropriate solution
On one of my sites, I also needed to cut off the ddos like connections, which was just connect and stay connected(where dosevasive is useless).
The squid proxy in accelerated mode before apache was a sollution for me...
Avatar of XoF
XoF

Have a look at my answer in this thread:

https://www.experts-exchange.com/questions/21416469/how-to-limit-concurrent-access-to-httpd-server-from-same-ip.html

Using the dstlimit match for iptables you should be able to block dos attacks even from changing source IPs.

HTH,

-XoF-
>  then..is there any way to limit access to certain pages within an interval of time?
you still have a rule posted yourself in the question to do that, why are you asking then?
> >  then..is there any way to limit access to certain pages within an interval of time?
> you still have a rule posted yourself in the question to do that, why are you asking then?

I think the emphasis was on "certain pages". In my understanding, the OP thinks of setting up limits for several different server (html) pages...  
The short & precise answer to that question is:
No, you can't accomplish that by means of iptables.

You could use iptables for such a purpose when using different official IP addresses and IP-based vhosts in apache, so you can set up different limits for each vhost.

HTH,

-XoF-
> The short & precise answer to that question is:
> No, you can't accomplish that by means of iptables.
disagreed, you can with the iptable's string match module
But I highly recommend to *not* use that for blocking HTTP requests, it's a waste of resources ...

Also: it does not make any sense to block request to URLs in the web server itself, 'cause the DDoS happens exactly there, hence the target victim tries to protect itself, which fails for obvious reason.
If you want to protect a web server based on URLs, you need a special device (phisical seperated hardware with special software) like a WAF (web application firewall), be prepared for $$$ ...
ASKER CERTIFIED SOLUTION
Avatar of XoF
XoF

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial