ִ DDOS

Ͽ Sukrit Dhandhania 2009 4 13

츮 縦 ޷ȴ ִ iptables ִ IP ּҸ ణ . 쿡 ݱ IP ּҸ ϴ  (DOS) ź ϴ ʴ ⿡ ִ.

̰ ϱ Ͽ 츮 Ҹ Ʈ ̿ ̴ psad. psad iptables õ ǥ ٸ ǽɽ 뷮 ˻縦 äϰ ˻ϴ ڿ iptables Ͽ .

۵DZ Ͽ, psad ġϽʽÿ. ޸ 쿡 Ubuntu ü谡 ִ dz̴ ü迡 psad ڿ ̵ ־:

# sudo ġѴ psad ´
Ǵ
# yum psad ġѴ

̰ psad Ӹ ۵ ʴ 쿡 ٿε ׸ ۵ϴ ü縦 ٿεϽʽÿ.

Ubuntu ϱ ڽ Ubuntu Ư ̴. ׷,  ̼ڿ ٸ dz̿ װͿ ־ մϴ. ʽÿ syslog.conf ⸦ :

# vim /etc/syslog.conf

ڿ ߰Ͻʽÿ:

kern.info |/var/lib/psad/psadfifo

޼ϴ ڿ ִ:

# - e "kern.info \ t|/var/lib/psad/psadfifo" >> /etc/syslog.conf

Ͻʽÿ sysklogd ׸ klog Ǹ:

/etc/init.d/sysklogd
/etc/init.d/klogd

psad װ iptables ϰ  ǽɽ IPs Ͽ ̴. ̰ ̿ϴ IP 𸣴. غϱ Ͽ IP ּ θ ϴ âؾ Ѵ. âϽʽÿ:

# vim /home/calvin/safeiplist.cfg

whitelist psad ʿ Ѵ IP ּҿ ʽÿ:

127.0.0.0 /24
192.168.0.0 /24
122.164.34.240

1 ʿ Ģ iptables ϱ Ͽ . iptables ü . 纻 ڿ Ǯĥϰ, üϰ WORKDIR ׸ SAFEIPLIST ü Ȯ .

WORKDIR= " /home/calvin/ "
INTERVAL= " 5 "
HITCOUNT= " 5 "
SAFEIPLIST= " safeiplist.cfg "

CD $WORKDIR

iptables - F
࿡ [- f $SAFEIPLIST]; Ŀ
IPS=$ (grep - Ev "^#" $SAFEIPLIST)
$IPS ִ i
[[do]]
iptables - Է - s $i - j
ϴ
fi

iptables - Է - m - ο - ֱ m - Ʈ
iptables -A INPUT -m state –state NEW -m recent –update –seconds $INTERVAL –hitcount $HITCOUNT -j LOG

What the script does is that it logs an IP address if it makes five or more attempts at making a connection in the span of five seconds. I would suggest you use the script as is unless you know what you are doing while modifying it. One you are done, give it executable permissions and run it.

# chmod +x /home/calvin/ipblock.sh

# /home/calvin/ipblock.sh

Now back to psad. Open the psad configuration file and edit it. These are the changes I suggest you make. Feel free to go through the psad documentation and make other changes:

EMAIL_ADDRESSES you@yourdomain.com;

Set machines hostname:

HOSTNAME yourdomain.com;

If you have only one network interface on this server, set HOME_NET to:

HOME_NET NOT_USED;

You can also need to adjust danger levels for psad, and define a set of ports to ignore, for example to ask psad ignore udp ports 80 and 8080, make the following change:

IGNORE_PORTS udp/80, udp/8080;

Save and close the file. Then restart psad:

# /etc/init.d/psad restart

You are now good to go. To monitor psads reports run the following command:

# psad -S

To remove automatically clocked IPs run the following command:

# psad -F

psad is a very versatile and powerful tool. If you know how to use it it can do wonders for you, but if you dont you can really mess up your computer. So please use psad with caution.

Related Posts:
  • How to block an IP address in IPTables in Linux
  • Comcast: Another chapter of lies, misdirection and ps. good luck using bittorrent
  • How to determine where all your hard drive space has gone in Windows
  • Getting started with iptables in Linux
  • An introduction to the sudo command and configuration file
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Just enter your email address below:

    You can always opt out of this email subscription at any time.

    { 0 comments add one now }

    Leave a Comment

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>