แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - golfreeze

Pages: 1 ... 143 144 [145] 146
2161
ฟอร์แมตแรกที่จะแนะนำก็คือ gzip ย่อมาจาก GNU zip คำสั่งก็ตรงไปตรงมาครับ ก็คือ

gzip filename.txt

หลังจากกด enter ไปไฟล์ filename.txt ของเราจะหายไป แล้วกลายร่างเป็น filename.txt.gz เสียแล้ว
แต่ใครยังอยากเก็บไฟล์ต้นฉบับไว้อยู่ก็ให้ใส่ -c เข้าไปซึ่งเป็นการบอกให้ gzip แสดงเข้ามาออกทาง
standard output จากนั้นเราก็ทำการเปลี่ยนทิศทางไปยังไฟล์ที่เราต้องการ

gzip -c filename.txt > filename.txt.gz

ผลลัพธ์ที่ได้ก็จะเหมือนกับคำสั่งแรกต่างกันที่ต้นฉบับเรายังอยู่ ไม่ไปไหน
และถ้าเราอยากให้ไฟล์ที่ได้บีบกันแบบสุดๆ ก็ให้ใส่ -9 แต่ถ้าอยากได้ความเร็วก็ใส่ -1
จริงแล้วเราสามารถใช้ค่าได้ตั้งแต่ -1 ถึง -9 อย่างเช่น

gzip -9 filename.txt

แต่ถ้าใครอยากใช้ -9 ตลอดแต่ไม่อยากพิมพ์ทุกครั้งก็ให้เซ็น environment variable ดังนี้

export GZIP="-9"

อะพอเราบีบเสร็จ ก็ต้องทำการแตกไฟล์ ก็ทำโดย

gunzip filename.txt.gz

และเหมือนเดิมไฟล์ .gz จะหายไป ถ้าไม่อยากให้หายก็ต้องทำอย่างนี้

gzip -c filename.txt.gz > filename.txt

เป็นยังไงสำหรับฟอร์แมตแรก ใช้ไม่อยากเลย อะฟอร์แมตที่สองที่จะแนะนำก็คงเป็น bzip2 นั่นเอง
ซึ่งอันนี้มาทีหลัง gzip แต่บีบได้เล็กกว่า รูปแบบคำสั่งก็จะคล้ายกัน ดังนี้

bzip2 filename.txt

เราก็จะได้ filename.txt.bz2 มา แต่ไฟล์ต้นฉบับก็จะหายไป
ถ้าไม่อยากให้หายไม่ต้องทำการเปลี่ยนทิศทางให้เมื่อยเหมือน gzip เพราะมี option -k มาให้ k ย่อมาจาก
keep ก็ใช้ง่ายๆ ดังนี้

bzip2 -k filename.txt

และเหมือนกันกับ gzip ซึ่งมีระดับการบีบอัด ตั้งแต่ 1 ถึง 9 ซึ่ง 1 จะใช้เวลาน้อยที่สุด ส่วน 9
จะบีบอัดได้สูงสุด

bzip2 -9 filename.txt

ไหนๆ ก็เหมือนกันมาเยอะแล้ว ก็ต้องกำหนดค่า default ได้โดย

export BZIP2="-9"

และถ้าเราอยากแตกไฟล์ออกก็ใช้คำสั่ง

bunzip2 filename.txt.bz2

ซึ่งไฟล์ .bz2 ก็จะหายไป ถ้าไม่อยากให้หายก็ใส่ -k ไปด้วยน้า

มาถึงคำสั่งสำคัญอีกคำสั่ง คือ คำสั่ง tar คำสั่งนี้ไม่ได้มีการบีบอัดใดๆ แต่จะเป็นการรวมไฟล์หลายๆ
ไฟล์ไว้เป็นไฟล์เดียวกัน รูปแบบคำสั่งก็จะเป็นดังนี้

tar -cvf test.tar filename.txt mydir

คำสั่งขั้นบนจะเป็นการนำไฟล์ filename และไดเร็กทอรี่ mydir มา tar แล้วเก็บไว้ในชื่อไฟล์ text.tar โดย
option c หมายถึงเป็นการสร้างไฟล์ tar -v เป็นการแสดงรายละเอียดขณะทำงาน และ -f
หมายถึงระบุชื่อไฟล์ที่เราต้องซึ่งก็คือ test.tar

อะและถ้าเราต้องการ extract ไฟล์ก็ทำได้โดย

tar -xvf test.tar

ซึ่ง -x หมายถึงการ extract นั่นเอง ขั้นตอนต่อไปจะเป็นการรวมพลังกันระหว่างการบีบอัดและการ tar
ถ้าเราต้องการรวมพลัง tar กับ gzip ก็ใช้คำสั่ง

tar -cvzf test.tar.gz filename.txt mydir

ซึ่งเราจะ tar ไฟล์ filename.txt และไดเร็กทอรี่ก่อน แล้วจึงทำการบีบอัดด้วย gzip แต่ถ้าใครชอบ bzip2
ก็ให้ใช้คำสั่

tar -cvjf test.tar.bz2 filename.txt mydir

จะเห็นว่าถ้าเป็น gzip เราจะใช้ option -z แต่ถ้าเป็น bzip2 จะเป็น -j อะดังนั้นถ้าเราต้องการ extract
ก็ให้ใช้คำสั่ง สำหรับ gzip

tar -xvzf test.tar.gz

และ bzip2 ก็จะเป็น

tar -xvjf test.tar.gz

เรียบร้อยครับ เป็นยังไงใช้กันไม่อยากครับ ตรงไปตรงมา ไปและ



Special Thank = http://www.logicdream.com

2162
มีปัญหาสั่งรัน crontab ไม่ได้

ให้เช๊คที่ ไฟล์

/etc/security/access.conf
comment ปิดที่ -:ALL EXCEPT root:LOCAL

ให้ comment เปิดที่ + : ALL : cron crond

แล้วลองสั่งรัน ใหม่ดูน่ะครับ

เพราะว่า มันกันไม่ให้ใครรัน crontab แม้จะเป็น root ก็ตาม

2163
string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (sames as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".

EXAMPLE CRON FILE

# use /bin/sh to run commands, overriding the default set by cron
SHELL=/bin/sh
#
# mail any output to `paul', no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
#
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
#
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"

2164
ปกติเราสามารถตั้งค่า MAILTO ใน crontab

เพื่อที่จะ ส่ง email ไปยังผู้ดูแลระบบได้ เมื่อรันคำสั่ง crontab

โดยแก้ที่

vi /etc/crontab

แก้ที่ MAILTO=root
เป็น
MAILTO=golfreeze[at]packetlove.com

ได้ครับ

เท่านี้ คำสั่ง crontab ที่รันก็ส่ง output ไปยัง email คนนั้นแล้วครับ

2165
สำหรับวิธีการให้ส่งเมล ไปถึง user ผู้รันคำสั่งนั้นๆ วิธีการคือ

ก็ไม่ต้องใส่คำสั่ง นี้ น่ะครับ
>/dev/null 2>&1

แต่ถ้าจะ disable email ก็ให้ใส่ คำสั่งนี้ ไปด้วยท้าย คำสั่ง crontab เช่น

*/5 * * * * root mrtg /etc/mrtg.cfg >/dev/null 2>&1
ครับ

2166
Examples for the Hour column:
8 = one value: execute in the 8 AM hour
5,6,9 = multiple values: execute in the 5, 6, and 9 AM hours
5-8 = range: execute in each hour between 5-8 AM (inclusive)
*/2 = fractional: execute in every other hour. 0 (midnight), 2AM, 4AM, 6AM, etc
3-12/3 = fractional range: execute in every third hour between 3AM and 12PM: 3AM, 6AM, 9AM, 12PM

Example:
5 */3 * * 1-5 cd "desktop/fold1"; ./fold &
This will launch on the 5-minute mark, every third hour, every day, every month, but only on days of
the work week (Mon-Fri). It cd's to the Desktop/Folding folder #1, then launches the launch
script in nohup mode so folding will keep running.

Example:
20,50 * * Jan-May,7-12 Mon-Fri cd "desktop/fold4"; ./foldlaunchscript
This will launch on the 20 and 50-minute marks, every hour, every day, every month except June (IT
desktop-inspection month), but only on days of the work week (Mon-Fri). It cd's to the
Desktop/Folding folder #4 on your Quad-CPU PowerMac, then launches the launch script which checks
for already-running instances of Folding before trying to launch another copy.

Example:
@reboot cd "/usr/local/mysql"; ./bin/safe_mysqld &
This will launch on each reboot. It cd's to the proper mysql root folder, then launches mysql
with the safe startup script in nohup mode.

Example:
12 * * * * cd "desktop/fold2"; ./foldlaunchscript
This will launch on the 12-minute mark, every hour, every day, every month, every day of the week.
It cd's to the Desktop/Folding folder #2, then launches the launch script which checks for
already-running instances of Folding before trying to launch another copy.

Example:
1 10 13 * 5 ./hiddenfolder/jokescript
This will launch at 10:01 AM, on any Friday the 13th. It launches your virus script.

Example:
14 2 29 8 5 ./skynet
This will launch at 2:14 AM, on August 29 if it is a Friday. It ends the world.

A special prefix (@AppleNotOnBattery ) can be added to the command line to only execute if the
laptop is running on external power - desktops are always plugged in when running, so a desktop will
always execute the command. This is an Apple extension, so it only works on Darwin (OSX) systems,
not Linux, BSD, or UNIX. I would expect it to work on x86 Darwin, but have no x86 laptop to test it
with. Using this command prefix on something that does not support it (like RedHat on a P4) will
cause an error.

Example:
45 23 * * * @AppleNotOnBattery ./Applications/Utilities/diskoptimizerscript
This will launch at 11:45 PM each day. It launches a disk optimizer, but only if your laptop is
plugged in to a power source.

2167
ปกติแล้ว เราสามารถตั้ง crontab ในลักษณะ นี้ ได้นะครับผม

@reboot = run at boot and reboot only
@yearly = run at midnight Jan 1 each year (equiv to 0 0 1 1 *)
@annually = run at midnight Jan 1 each year (equiv to 0 0 1 1 *)
@monthly = run at midnight on the first day of each month (equiv to 0 0 1 * *)
@weekly = run at midnight each Sunday (equiv to 0 0 * * 0)
@daily = run at midnight each day (equiv to 0 0 * * *)
@midnight = run at midnight each day (equiv to 0 0 * * *)
@hourly = run on the first second of every hour (equiv to 0 * * * *)
- or -
1 2 3 4 5 = specific time tags
- where -
1 = Minute (of hour) to activate [0-59]
2 = Hour (of day) to activate [0-23]
3 = Day (of month) to activate [1-31 ... 29,30,31 may not activate during all months]
4 = Month (of year) to activate [1-12 or 3-letter names "Jan,Feb,Mar"]
5 = Weekday to activate [0-6 or 3-letter names "Mon,Tue,Wed"]  (0=Sunday)

2168
http://www.webhostingtalk.com/showthread.php?p=5070700

แก้ bug

แก้ bug เรื่อง filemanager

Edit files:
/etc/vhcs2/apache/parts/als_entry.tpl
/etc/vhcs2/apache/parts/als_php2_entry.tpl
/etc/vhcs2/apache/parts/dmn_entry.tpl
/etc/vhcs2/apache/parts/dmn_php2_entry.tpl
/etc/vhcs2/apache/parts/sub_entry.tpl
/etc/vhcs2/apache/parts/sub_php2_entry.tpl

แล้วแก้ไขไฟล์ โดยลบ / หลัง /tmp/ ออกครับให้เหลือแค่

/tmp ในไฟล์เหล่านี้

เช่น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp/"
แก้เป็น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp"

ถ้าทำเสร็จหมดแล้วทำการ อัฟเดท vhcs2.conf ใหม่ดังนี้ ครับ

/etc/init.d/vhcs2_daemon stop
mysql -u root -p<password>
USE vhcs2
UPDATE `domain` SET `domain_status` = 'change' WHERE `domain_status` = 'ok';
UPDATE `domain_aliasses` SET `alias_status` = 'change' WHERE `alias_status` = 'ok';
UPDATE `subdomain` SET `subdomain_status` = 'change' WHERE `subdomain_status` = 'ok';
quit
/var/www/vhcs2/engine/vhcs2-rqst-mngr
/etc/init.d/vhcs2_daemon start

มีปัญหาก็สอบถามไว้ได้ น่ะครับ

##ปรับ timezone ของ debian ให้เป็นเวลา malaysia

cp /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

2169
แก้ไข ไฟล์ /etc/php5/cli/php.ini
แล้วแก้ไข ไฟล์

vi /etc/apache2/sites-enabled/vhcs2.conf
จาก
php_admin_value open_basedir
'/var/www/vhcs2/gui/tools/filemanager/:/tmp/:/usr/share/php/'
เปลี่ยนเป็น
php_admin_value open_basedir
'/var/www/vhcs2/gui/tools/filemanager/:/tmp:/usr/share/php/'

2170
แก้ ให้ ftp ได้ดังนี้

Step 1: Backups

nano /etc/proftpd.conf
the do a ^X (Ctrl + X) and save it as /etc/proftpd2.conf

Step 2: Delete BS Config

nano /etc/proftpd.conf
Remove everything above the "#VHCS2 Management;" Line.
Save the Doc and Exit (Ctrl + O, Ctrl + M, Ctrl + X).

Step 3: Include the VHCS FTP File

nano /etc/proftpd/proftpd.conf
Find the line
#<IfModule mod_sql.c>
# SQLBackend mysql
#</IfModule>

And make it look like this
<IfModule mod_sql.c>
SQLBackend mysql
Include /etc/proftpd.conf
</IfModule>
Save and exit the document.

Step 4: Disable PostgresSQL Module

nano /etc/proftpd/modules.conf
Comment out the following line
LoadModule mod_sql_postgres.c
Save and Exit

Step 5: Restart ProFTP
/etc/init.d/proftpd restart
You may also want to reboot your machine, but thats
completely optional. However that is all that needs to be
done.

2171
วันนี้ลองใช้งาน mail Client ใน VHCS ดูครับซึ่งเป็นตัวของ UebiMiau ที่ลงมากับตัว VHCS พอลองสร้าง
account ดูก็ไม่มีปัญหาอะไรแต่พอ login เข้าใช้งานก็เจอ message นี้ครับ
ERROR (2): Header may not contain more than a single header, new line detected.
(/var/www/vhcs2/gui/tools/webmail/inc/inc.php:155)
พอลอง search ใน google ดูก็พอเจอ แนวๆว่าให้เข้าไปแก้ไฟส์ inc.php นั้นซะซึ่งโหลดมาแก้ดังนี้คือ จาก
บันทัดที่ 155
Change :

Header("Expires: Wed, 11 Nov 1998 11:11:11 GMTrn".
"Cache-Control: no-cachern".
"Cache-Control: must-revalidate");
to

Header("Expires: Wed, 11 Nov 1998 11:11:11 GMT");
Header("Cache-Control: no-cache");
Header("Cache-Control: must-revalidate");
Save, and exit. แล้ว copy ไปไว้ที่เดิมคราวนี้ก็ลอง refresh ดูแล้ว login เข้าใช้งาน mail client
ก็สามารถใช้งานได้ปกติครับ อิอิเมลล์ใหม่คือ golfreeze@packetlove.com ครับ

2172
วันนี้ พอดีมีเครื่อง R200 มาให้เล่นก็เลย ลองลงเป็น debian 4.0 R3 64 bit
กับ vhcs2 ครับ

ลองมาดูขั้นตอนกันเด้อ ซู

ก่อนอื่นลง OS ตั้ง ip เสร็จ ก็มาแก้ไข sources.list ให้โหลด package ในไทยตามนี้เด้อ

#vi /etc/sources.list

deb http://ftp.thaios.net/debian/etch main
deb-src http://ftp.thaios.net/debian/etch main

ทำการ update และ upgrade package
#apt-get update
#apt-get upgrade
แล้วทำการลง ssh ก่อนโดย

#apt-get install ssh

แล้วทำการลง package ต่างๆ ที่จำเป็นที่จะใช้ดังนี้

ลง MySQL server (MySQL5):

#apt-get install mysql-server mysql-client libmysqlclient15-dev phpmyadmin

แก้ไขให้ client connect ไปที่ mysql server ได้ทุกแบบไม่ใช่แค่ "localhost"
#vi /etc/mysql/my.cnf

หาบันทัด bind-address = 127.0.0.1 แล้วใส่ # ไปซะ
# bind-address = 127.0.0.1

ทำการ restart MySQL:
#/etc/init.d/mysql restart

ใส่ค่า password ของ mysql
#mysqladmin -u root password yourpassword

ต่อไปทำการ install Apache 2(.2) with PHP5

#apt-get install apache2 apache2-doc apache2-mpm-prefork apache2.2-common apache2-utils libexpat1 ssl-cert

และต่อไป install php5

#apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear
php5-imagick php5-imap php5-json php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-ps
php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

จะขึ้น Pop-up ถามว่า

Continue installing libc-client without Maildir support?

ตอบไปว่า yes

แก้ไข config apache ดังนี้

DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml

แก้ไขไฟล์ /etc/apache2/ports.conf

โดยเพิ่ม Listen 443:

#vi /etc/apache2/ports.conf

Listen 80
Listen 443

ทำการเปิด module ต่างๆ ที่จะใช้ใน apache
#a2enmod ssl
#a2enmod rewrite
#a2enmod suexec
#a2enmod include

ทำการ reload config apache
#/etc/init.d/apache2 force-reload

ต่อไปทำการลง mail server
#apt-get install postfix postfix-tls

จะถามค่า hostname
ใส่ให้ตรงกับ ตอนที่ install os
เช่น server1.example.com

#apt-get install proftpd proftpd-mysql

เลือกเป็นแบบ "Stand alone"

#apt-get install courier-authdaemon courier-base courier-imap courier-maildrop courier-pop
libberkeleydb-perl libcrypt-blowfish-perl libcrypt-cbc-perl libcrypt-passwdmd5-perl libdate-calc-perl libdate-manip-perl libdbd-mysql-perl libdbi-perl libio-stringy-perl libmail-sendmail-perl libmailtools-perl libmd5-perl libmime-base64-perl libmime-perl libnet-dns-perl
libnet-netmask-perl libnet-perl libnet-smtp-server-perl
libperl5.8 libsnmp-session-perl libterm-readkey-perl libtimedate-perl perl perl-base perl-modules
bind9 diff gzip iptables libmcrypt4 patch procmail tar original-awk libterm-readpassword-perl
libsasl2-modules libsasl2 sasl2-bin bzip2 gcc make libc6-dev

แก้ไขไฟล์ /etc/proftpd/proftp.conf ดังนี้

#vi /etc/proftpd/proftpd.conf

UseIPv6 off

เพิ่ม config นี้ลงไป

DefaultRoot ~
IdentLookups off
ServerIdent on "FTP Server Ready"

ทำการ save แล้วออกไป.

ต่อไปทำการ download package vhcs2 มาคับตัวนี้ สามารถ support ได้ทั้งแบบ 64 bit กับ 32 bit น่ะครับ

#cd /usr/src
#wget http://downloads.sourceforge.net/vhcs/vhcs2-2.4.7.1.tar.bz2

แตกไฟล์:
#tar -xjf vhcs2-2.4.7.1.tar.bz2

เข้าไปยัง
#cd vhcs2-2.4.7.1

สั่งรัน เพิ่มให้สร้างตัว install :
#make install

หลังจากนั้นเข้าไปที่
#cd /tmp/vhcs-2.4.7.1

ทำการ copy file ไปยังปลายทาง:
#cp -R * /

##แก้ path fix error ftp ผ่านเว็บครับ

แก้ bug เรื่อง filemanager

Edit files:
/etc/vhcs2/apache/parts/als_entry.tpl
/etc/vhcs2/apache/parts/als_php2_entry.tpl
/etc/vhcs2/apache/parts/dmn_entry.tpl
/etc/vhcs2/apache/parts/dmn_php2_entry.tpl
/etc/vhcs2/apache/parts/sub_entry.tpl
/etc/vhcs2/apache/parts/sub_php2_entry.tpl

แล้วแก้ไขไฟล์ โดยลบ / หลัง /tmp/ ออกครับให้เหลือแค่

/tmp ในไฟล์เหล่านี้

เช่น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp/"
แก้เป็น
php_admin_value open_basedir "{GUI_ROOT_DIR}/:/etc/vhcs2/:/proc/:{WWW_DIR}/:/tmp"

แล้วเข้าไปที่ :
#cd /var/www/vhcs2/engine/

ทำการแก้ไข file vhcs2_common_code.pl
#vi vhcs2_common_code.pl

ใช้ vi เข้าไปแก้ บันทัดที่ "1408" หาคำว่า:
'key'=>$main::db_pass_key,

เพิ่มบันทัดนี้เข้าไปก่อนหน้า นั้น
'keysize'=>32,

ระวังเครื่องหมายด้วยน่ะครับ
แก้ที่บันทัด ประมาณ 1446 ให้ใส่ตามข้างบนนั้น


save แล้วออกมา.

เริ่มทำการ install vhcs ครับ
#cd /var/www/vhcs2/engine/setup
#./vhcs2-setup

2173
บางครั้ง เราอาจจะใช้วิธีหา ข้อความที่เป็นคำสั่งใน file ของ user ได้
คือผมเคยมี case หนึ่งซึ่งหาด้วยวิธีอื่นไม่เจอจริงๆ เลยใช้วิํธี หาโดย

#cd /folder/problem

#ใช้คำสั่ง ค้นหา
#find . -iname '*.*' -print | xargs grep -il 'mail'

และสามารถเช๊ค connection ได้คือ
netstat -anp | grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

เช๊คดูการทำงานของ disk , utilization
#iostat -x 2

เช๊คดูการทำงานของ การเขียน อ่าน disk
#iotop

2174
First aid for DDOS attack on port 80

First aid for DDOS attack on port 80

We can use the following steps to recover our server from a DDOS attack on the port 80. To do this
you must have logged into the server as a root user.



Step 1 : Install/Configure APF firewall
=============================

a) If there are no firewalls installed on the server please install the same,
you will get the steps and directions from the following site.

http://www.webhostgear.com/61.html


b) Turn on the antidos option (USE_AD) in the APF conf file

# vi /etc/apf/conf.apf

USE_AD = 1




Step 2 : Install/Configure mod_evasive (for Apache 1.3x)
=============================


mod_evasive and mod_dosevasive are the same

a) Install mod_evasive

# wgethttp://www.zdziarski.com/projects/mo..._1.10.1.tar.gz
# tar -xzvf mod_evasive_1.10.1.tar.gz
# cd mod_evasive

# /usr/local/apache/bin/apxs -i -a -c mod_evasive.c
# /etc/init.d/httpd restart


b) Also include the following lines in the apache conf file

# vi /usr/local/apache/conf/httpd.conf

-------------------------------------------------

DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10

-------------------------------------------------


c) Restart the webserver

# /etc/init.d/httpd restart





Step 3 : Install mod_security
=============================



Normally we can find/install this module from WHM
WHM >> cPanel >> Addon Modules >> Select "modsecurity "
>>save






Step 4 : Blocking IPs

a) Find the IPs those have established a connection with the server

(The following command is the better one to get the IPs, as this will sort the IPs
according to the number of connections).


netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n


b) Block them using IPTABLES

# iptables -I INPUT -s 218.92.207.28 -j DROP
# service iptables save
# service iptables restart


c) Block them on APF too

# vi /etc/apf/deny_hosts.rules


# service apf restart




Step 5 : Optimizing the httpd.conf file
=============================


# vi /usr/local/apache/conf/httpd.conf

Change the bellow options as follows, original values are shown in the
bracket.

MaxKeepAliveRequests 50 (100)
KeepAliveTimeout 60 (30)


Also edit the following options too, according to the situation.

Timeout
KeepAliv
MinSpareServers
MaxSpareServers
MaxClients




Step 6 : Install/Configure 3rd party DDOS prevention tools
=============================

We can also use the most trusting 3rd party script 'DDoS-Deflate' for preventing DDOS attack
effectively.
Steps to install this script are as follows.

# wgethttp://www.inetbase.com/scripts/ddos/install.sh
# sh install.sh

Add the script '/usr/local/ddos/ddos.sh' to cron as follows

# crontab -e

*/5 * * * * /usr/local/ddos/ddos.sh >/dev/null 2>&1





Step 7 : Suspend websites
=============================

Check the bandwidth usage of all the domains and suspend the high bandwidth consuming domains for a
while





PERMANENT WAY TO FIX THE DDOS ATTACK
=============================

As we all know the softwares have its own limitations for preventing against DDOS attack, we can
follow these steps to cure it permanently.

1. Ask the NOC for attaching Cisco Guard on the server for 24 hours
(Normally this service is free from most NOCs)

2. Attach a hardware firewall for the server



Hope this will help you in such a situation, for more information kindly refer the following URL:
http://forums.cpanel.net/showthread.php?t=66952

2175
ddos command

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
route add 12.219.178.143 reject
route add 202.173.147.138 reject

===============

netstat -a | grep SYN | wc -l
iptables -A INPUT -s 124.177.148.139 -j DROP
#List ip ไหนว่ามี connection กี่ครั้งเข้ามาที่ server
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Pages: 1 ... 143 144 [145] 146