Linux Script

Need to write a simple shell script ( Ubuntu/CentOS) that is ran using crontab, idea is to scan for number of connections per ip, if it exceeds specified limit, run command to block that IP in our firewall.


1. run netstat -atun | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n

2. scan number of connections and IP addresses

sample output:

2 [login to view URL]

2 [login to view URL]

3 [login to view URL]

5 [login to view URL]

5 [login to view URL]

5 [login to view URL]

6 [login to view URL]

6 [login to view URL]

8 [login to view URL]


10 [login to view URL]

12 [login to view URL]

22 [login to view URL]

22 [login to view URL]

24 [login to view URL]

24 [login to view URL]

60 [login to view URL]

370 [login to view URL]

450 [login to view URL]

Threshhold limit in conf is for ex 200 that means the last 2 ips should be blocked using command:

csf -d [login to view URL]

csf -d 450 175.137.180

use sendmail to email this event (only if block was done)

Must work without bugs/crashing/memory leaks etc, at end of script it must be terminated.

Skills: Linux, Shell Script, C Programming, UNIX, Ubuntu

See more: linux script mysql sync, dash linux script, linux script manager users, linux script error handling, linux script probleme, linux script replace string file, linux script update database, linux script imagemagick, html2pdf linux script, tag cloud script need script tag pictures, linux script backup lto, linux script transferring files sftp, linux script setting server, linux script download email attachments, read the numbers and decide what the next number should be 15 14 13 12 11 10 9

About the Employer:
( 2 reviews ) Ajax, Canada

Project ID: #21701231

Awarded to:


Hello Hope you are doing well. I have 7 years of experience in Linux and shell scripting. I can handle this project. Regards VishnuLal*

$50 USD in 1 day
(145 Reviews)

3 freelancers are bidding on average $133 for this job


Hi I am software engineer and have done many programming and technical projects. Send me more details about your application so that we can negotiate the price accordingly. Thank you

$300 USD in 7 days
(44 Reviews)

Hello, I'm a software engineer & linux sysadmin. I can do this, I used CSF before for DDoS attacks from haters, I lost my script but I can recreate it for you. It will work safetly but can't guarantee the memory and C More

$50 USD in 7 days
(10 Reviews)