Portal Home > Knowledgebase > Articles Database > Server shoutdown


Server shoutdown




Posted by Markovic, 10-11-2009, 02:53 AM
Hello, I'm getting DDoS'd and my VPS provider suspends my VPS every time when it happens. How could I make in bash scripting to if there is more than 500 connections to the server to server just shoutdown. And to check every 1 min for connections(cron)? Thanks

Posted by TheServerExperts, 10-11-2009, 02:57 AM
Did you already try http://deflate.medialayer.com/ Cheers

Posted by Markovic, 10-11-2009, 03:55 AM
Yes, it fails because the attack is too big. I didn't ask for ddos protection, I tried almost everything, If you know, please answer at my 1st question

Posted by Markovic, 10-11-2009, 10:47 AM
I coded this but it fails: #!/bin/sh function DDoS { netstat -ntu | awk '{print $10}' | cut -d: -f1 | sort | uniq -c | sort -n } if [ DDoS > 500 ]; then /sbin/poweroff fi I got an error: ./ddos.sh: line 7: [: DDOS: integer expression expected Any suggestions?

Posted by nomankhn, 10-11-2009, 11:52 AM
you cant use function like that better use like that.

Posted by Markovic, 10-11-2009, 12:00 PM
If I put touch test instead of poweroff, whatever I put < or > it creates test file. What's wrong?

Posted by nomankhn, 10-11-2009, 12:34 PM
Please post script that is in your mind.

Posted by Markovic, 10-11-2009, 02:01 PM
Hello, I got the script to work but I have the problem with cron now. here is the output of crontab -l: # m h dom mon dow command 0-59/1 * * * * root /root/ddos.sh The script is supposed to run every 1 minute, ddos .sh is chmoded to 755. Only for testing purposes I set the script to send an email of there is less than 500 connections to the server. When I run it like ./ddos.sh it sends en email but itt's supposed to be running every 1 minute via cron and it's not sending me emails and it makes me think the script isn't even start by cron. I restarted cron after I added the script in it and cron is running, I checked via ps aux. Any help would be appreciated

Posted by nomankhn, 10-11-2009, 02:10 PM
cron seems ok , i use below cron anyway. */1 * * * * root /root/ddos.sh its better you post your script, you can pm script if you dont want to post on thread, i am not sure where the problem is without seeing script.

Posted by Markovic, 10-11-2009, 02:24 PM
bin/sh ddos=`/bin/netstat -ntu | awk '{print $10}' | cut -d: -f1 | sort | uniq -c | sort -n` if [ $ddos -lt 500 ]; then echo "test" | sendmail -s maemail@gmail.com fi When I execute it like ./ddo.sh it works, but in cron it doesn't work. Pretty weird

Posted by nomankhn, 10-11-2009, 02:34 PM
Please check below one.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Language: