我們跑了文章 如何阻攔一個IP地址在iptables在Linux 幾天前。 這展示您如何在的情況下查出攻擊者IP地址取消服務的一篇免費文章(或DOS)攻擊。
要做此我們將使用叫的免費軟件 psad. psad 工作同步iptables採伐并且檢查港掃瞄和其他可疑交通通常是設法的某人的標誌打破您的Linux服務器的iptables和顯示器。
要開始,安裝psad。 如果您跑有一個花梢包裹管理系統像Ubuntu或淺頂軟呢帽您Linux的味道在您的系統應該能使用以下命令之一得到psad :
# sudo易於得到安裝psad
或
# yum安裝psad
如果這不為您運作頭對psad 下載頁 并且下載為您運作的格式。
因為我使用一臺Ubuntu Linux服務器其餘本指南將是Ubuntu具體。 然而,以某些未成年人扭捏您在Linux其他味道應該能做它工作。 打開 syslog.conf 文件用您喜愛的文本編輯程序:
#精力/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地址名單的文件。 創造一個文件像這一個:
#精力/home/calvin/safeiplist.cfg
進入IP地址您需要psad對whitelist :
127.0.0.0 /24
192.168.0.0 /24
122.164.34.240
沒有用途一個劇本像跟隨一配置iptables以必要的規則。 筆記 這個劇本從您的iptables設定將去除所有早先設置。 拷貝和在您的Linux服務器黏貼以下劇本,并且替換可變物 WORKDIR 并且 SAFEIPLIST 與正確設置從您的設定。
WORKDIR= " /home/calvin/ 「
INTERVAL= " 5 "
HITCOUNT= " 5 "
SAFEIPLIST= " safeiplist.cfg "
CD的$WORKDIR
iptables - F
如果[- f $SAFEIPLIST]; 然後
IPS=$ (grep - Ev 「^#」 $SAFEIPLIST)
為i在$IPS
[[do]]
iptables -輸入- s $i - j受理
做
fi
iptables -A INPUT -m state –state NEW -m recent –set
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 machine’s 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 psad’s 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 don’t you can really mess up your computer. So please use psad with caution.

























{ 0 comments… add one now }
Leave a Comment