แสดงกระทู้

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 ... 144 145 [146]
2176
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.

2177
ปกติแล้ว เราสามารถตั้ง 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)

2178
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

2179
แก้ไข ไฟล์ /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/'

2180
แก้ ให้ 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.

2181
วันนี้ลองใช้งาน 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 ครับ

2182
วันนี้ พอดีมีเครื่อง 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

2183
บางครั้ง เราอาจจะใช้วิธีหา ข้อความที่เป็นคำสั่งใน 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

2184
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

2185
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

2186
#พอดี เครื่องที่ได้ดูแล มีปัญหาเรื่อง perl script น่ะครับ ลักษณะคือมีการรัน perl5.7 อยู่ซึ่งเป็น
user apache สำหรับวิธีการ tracking หาต้นตอ นั้น ขอให้มีสติ ให้นิ่งก่อน แล้วเริ่มใช้วิธีง่ายๆ ดังนี้
ครับ
1.find command

#find / -user apache -name "*.pl"
#find / -user apache -name "*.txt"

ดูเจอไฟล์ไหนแปลกๆ ก็เข้าไปดูครับ

2.จะเข้าไปดูตาม log ของ access กับ error_log ใน apache ครับ
#less /var/log/httpd/access_log
#less /var/log/httpd/error_log

3.เข้าไปใน ไฟล์พวก log ของ ไฟล์ ftp log
#less /var/log/xferlog

4.อีกวิธีที่ผมชอบใช้ คือ ใช้ตัว application มาช่วย คือตัว lsof

ตัวนี้ เก๋าพอสมควร ซึ่งมันจะ หา ip ที่ connection "ESTABLISH" อยู่

และบางทีอาจปรากฏเป็น path ที่รันไฟล์อยู่ด้วย เราก็เข้าไปจัดการได้เลย

#lsof -i -n -P | more
ถ้าเจอ ip ที่เชื่อมต่อก็ block เพื่อตัดปัญหาที่ปลายทางไปก่อนก็ได้ครับ

5.ลองดู crontab ของ user นั้นๆเช่น
#crontab -u apache -l
ถ้าเจอ ก็ตามไปดู ไฟล์นั้น

6.ทำการ ตรวจไวรัสโดยใช้ tools clamscan ช่วย
#clamscan /

ึ7.ถ้าไม่เจอ จริงๆ แล้วล่ะก็ทำการ Killall process นั้นทิ้งซะ เช่น
#killall -9 perl5.7.8


ซึ่งปัญหาที่เกิดขึ้น แอดมินแต่ล่ะคนก็ แก้ปัญหาตามสไตส์ที่ตนเองถนัด สำหรับผมก็จะใช้ประมาณนี้
เลยอยากมาแชร์ให้เพื่อนๆ ได้ทราบ เผื่ออาจจะช่วยท่านได้บ้าง

แต่สุดท้าย ทุกอย่างก็ล้วนไม่มีอะไรสมบูรณ์ มันเป็น อนิจจัง ครับ

golfreeze[at]packetlove.com

2187
#คำศัพท์ เกี่ยวกับ DNS

ความหมาย/หน้าที่
Forward Master Zone
แปลงชื่อ Domain เป็น IP Adress

Reverse Master Zone
แปลง IP Adress เป็นชื่อ Domain

BIND(Berkeley Internet Name Domain)
โปรแกรมให้บริการดีเอ็นเอส

Quote
bind-utils-9.2.4-2
bind-9.2.4-2
bind-libs-9.2.4-2
ypbind-1.17.2-3
bind-chroot-9.2.4-2

Master Name Sever

Slave Name Server Name Server มีสองแบบคือ Master Name Sever และ
Slave Name Server ซึ่งจะต้องอยู่ต่างเครื่องกัน

Master Name Server จะอ่านข้อมูลประจำโซนจากแฟ้มใน Disk และมีสิทธิหน้าที่ในโซนนั้นๆ
Slave Name Server สำเนาข้อมูลจาก Master Name Server

named โปรแกรมบริการชื่อ Domain บน Linux

/usr/sbin/named -u named -t /var/named/chroot
Host
เครื่องคอมพิวเตอร์ศูนย์กลางที่ต่อเข้ากับ Network,Internet เพื่อบริการใดๆ

Domain
ชื่อ web address/computer
ทำให้เข้าใจ/จำง่าย/มีความหมาย กว่า IP Address

ถ้าเรียก โดเมน เหมือนเรียก IP Address

http://www.icann.org/

Sub Domain
ส่วนย่อยของ Domain เช่น mail.dns.linuxstep.com
mail คือ Sub Domain
Localhost = เครื่องเราเอง จะตั้งค่า ip address อะไร แต่เมื่อเรียก
Localhost ก็จะเรียกเครื่องเราเอง

IP Address 127.0.0.1 = Localhost
IP(Internet Protocal)
IP หรือ Internet Protocal
IP Address คือรหัสตัวเลขที่กำหนดขึ้น เพื่อใช้อ้างถึงที่อยู่ของ Host และ Network
ตัวเลขเหล่านี้จะไม่ซ้ำกัน (unique numeric) ซึ่งมีมาตรฐานในการกำหนด และเป็นที่รู้จักทั่วโลก IPV4,IPV6
Port ช่องทาง ที่ใช้ติดต่อกับ computer/อุปกรณ์ ใน network

(Address Localhost)
สำหรับ window กำหนด loopback IP=127.0.0.1 เมื่อส่งสัญญาณออกจะไม่ส่งออกนอกเครือข่าย แต่จะกลับมา
ที่ต้นทาง ด้วย loop back driver

http://www.certiguide.com/netplus/
cg_np_IVLoopbackAddressingandConnections.htm

Root Domain ตอนนี้มีอยู่ 13 ตัวทั่วโลก
ลำดับบนสุดของระบบ DNS โดยมีการกำหนดดังนี้
ลำดับที่ 1 root
ลำดับที่ 2 .com, .net, .edu, .gov, .org, .th, ...
ลำดับที่ 3 subdomain ตัวอย่าง mail3.linuxstep.com
mail3 =subdomain

ตัวอย่างลำดับ DNS
www2.dns.linuxstep.com

Name Resolution

การที่ DNS Server เก็บหมายเลข IP Address คู่กับชื่อเครื่องแบบ Domain Name
เพื่อทำการค้นหาชื่อตามการร้องขอของเครื่อง DNS client
DNS Server
เครื่องที่คอยจัดการ/ดูแล/แก้ไข domain subdomain
Client
เครื่องลูกข่าย
Resolver
กลไกการแปลง domain เป็น ip address
Reverse File
/etc/resolve.conf

การ resolve หมายถึง
DNS Zone
การจัด domain เป็นพื้นที่ย่อย
TCP,UDP,ARP

เป็น protocol ที่ DNS ใช้ในการติดต่อผ่าน port 53

TCP - ปรับปรุงข้อมูล
UDP - ส่งคำขอข้อมูล
ARP - แปลงค่า IP address เป็น Hardware

#Files ที่ใช้ในการ Config
Files Config

ความหมาย / หน้าที่
/etc/named.conf
กำหนดการทำงานของ Name Server สำคัญมาก
/var/named/named.ca เก็บข้อมูลชื่อ Server ซื่งเป็น Root Name Server
ไม่ควรแก้ไขข้อมูลใน file นี้เป็นอันขาด
/var/named/named.local เก็บข้อมูลการ map ชื่อ กับ IP Address แบบ Reverse Lookup
/var/named/dm.com.zone ระบุชื่อ Server,Zone, ทำ Forward Lookup
/var/named/ 203.203.203.203.zone

Reward Lookup
/etc/hosts
เก็บชื่อ host
/etc/resolve.conf
เก็บชื่อ domain และ ip ที่ทำงานแบบ Forward Lookup
/etc/sysconfig/network เก็บชื่อ host ของเครื่อง
/etc/sysconfig/named กำหนดตำแหน่งของ named ที่เป็น file config

#ความหมายของ SOA Resource Record
SOA (Start to authority)
เริ่มให้สิทธิ/อำนาจ

ความหมาย / หน้าที่

Domain Name ที่ได้จาก /etc/named.comf
IN Internet
serial = เป็นหมายเลขที่ใช้แสดงการอัพเดทข้อมูลระหว่าง Primary master และ Secondary master
refresh = ระยะเวลา refresh ข้อมูล
retry = ระยะเวลา ตรวจสอบข้อมูลกับ Primary DNS Server
expire = ระยะเวลา หมดอายุ กรณีติดต่อกับ Primary DNS Server ไม่ได้

#ความหมายข้อมูลใน Fields Type DNS Record
Type

ความหมาย / หน้าที่
A = แปลงชื่อ Domain เป็น IP Address แบบ ipv4
NS = Name Server record กำหนดว่า server ใดรับผิดชอบ domain
PTR = Pointer record ใช้ Map IP Address เป็น Host

MX = Mail Exchanger
ใช้ระบุชื่อเครื่อง Mail Server ของ Domain
เมื่อเราต้องกำหนด MX เราจะพบว่าต้องกำหนด
MX 10 mail1.example.com
MX 20 mail2.newdomain.com

ค่าเลข 10 และ20 นั้นหมายถึง Priority ของ Mail โดยค่าน้อยสุดจะสำคัญสุด

ชื่อหลัง MX ต้องเป็น Domain เท่านั้นและไม่ใช่ CName
CNAME = Cononical name ใช้เป็น Alias name ให้เป็น host จริง
เช่น ns,mail,www,www2
;
Remark


2188
ลง mailgraph + syslog-ng ใน freebsd

#cd /usr/ports/mail/mailgraph
#make install clean

เพิ่มใน /etc/rc.conf ตามนี้
mailgraph_enable="YES"
mailgraph_pidfile="/var/db/mailgraph/mailgraph.pid"
mailgraph_flags=""
logfile /var/log/maillog
"daemon-rrd=/var/db/mailgraph "ignore-localhost "daemon
"daemon-pid=${mailgraph_pidfile}"
mailgraph_user="root"
mailgraph_group="wheel"
สั่งให้ service ทำงาน
/usr/local/etc/rc.d/mailgraph start
ถ้าทำงานแล้วสั่ง
#/usr/local/etc/rc.d/mailgraph status
จะเป็น
mailgraph is running as pid 4406.

SYSLOG ธรรมดา
กรณีให้ส่ง log maillog มาจาก เครื่อง client (smtp0 , smtp1)
ฝั่ง client ที่ต้องการให้ ส่ง log มายังเครื่อง server ก็
ให้เข้าไปแก้ไข ใน
#vi /etc/syslog.conf

ยกตัวอย่างเช่น
ให้ maillog ส่ง log มาที่เครื่อง log server(xxx.yyy.zzz.100) ก็เพียงแค่

# ให้เก็บที่เครื่องตัวเอง กับส่งมาที่ ip xxx.yyy.zzz.100
mail.* -/var/log/maillog
mail.* @xxx.yyy.zzz.100

แล้วจัดการ save
แล้วสั่งให้ syslog ที่เครื่อง client restart 1 ครั้ง

#ตระกูล RH
/etc/init.d/syslog restart

แค่นั้นแล้วไปรอดูที่ cacti_syslog ครับ


แล้วไป config ให้ mailgraph.cgi ให้แสดงรูปให้ถูกที่

แล้วทำการสั่งให้ mailgraph ทำงานโดยเข้าไปเรียก

#/usr/local/sbin/mailgraph.pl --logfile /var/log/customer-maillog/maillog-total
--daemon-pid=/var/db/mailgraph/mailgraph.pid --daemon

ดูว่า service ทำงาน
#/usr/local/etc/rc.d/mailgraph status
จะเป็น
mailgraph is running as pid 4406.
ประมาณนั้น


ส่วนของ syslog-ng ( ฝั่ง server จะเป็น ) นั้น จะอยู่ที่

/usr/local/syslog-ng/syslog-ng.conf

สำหรับ config หลักๆ เป็น

source s_maillog_smtp0 { tcp(ip(116.68.146.13) port(21245)); }; #ควรตรงกับฝั่ง client
destination d_maillog_smtp0 { file("/var/log/customer-maillog/maillog-smtp0"); };
log { source(s_maillog_smtp0); destination(d_maillog_smtp0); }; #สามารถใส่ค่า filter ต่างได้ที่
ในส่วนของ "log" น่ะครับ
ข้อแนะนำ ส่วนของ filter สามารถใช้งานได้ดี เมื่อ log ที่ถูกส่งเข้ามาที่ server มีปริมาณไม่มากเกินไป
จะทำงานได้ ดี
แต่ ถ้ามีปริมาณเข้ามาเร็ว แนะนำ ให้ ส่วนของ client ทำการ ส่งเข้ามาเป็น socket แยก เลย ลองมาดูฝั่ง
client บ้างน่ะครั บ

options {
use_fqdn(no);
sync(0);
};

source s_maillog { unix-stream("/dev/log" max_connections(1000));
pipe("/proc/km
sg"); internal(); };
source s_file { unix-stream("/dev/log"); pipe("/proc/kmsg"); internal();
};

destination d_maillog { file("/var/log/maillog"); };
destination d_backup { tcp("10.20.0.252" port(20245)); }; # socket ควรส่งไปให้ ตรงกับ
ฝั่ง server น่ะครับ
destination d_tools { tcp("116.68.146.13" port(20245)); };# socket ควรส่งไปให้ ตรงกับ
ฝั่ง server น่ะครับ

destination d_tools_1 { tcp("116.68.146.13" port(21245)); };


log { source(s_maillog); destination(d_backup); };
log { source(s_maillog); destination(d_tools); };
log { source(s_maillog); destination(d_tools_1); };
log { source(s_maillog); destination(d_maillog); };

เมื่อ config เสร็จทั้งสองฝั่ง สั่งให้ restart service syslog-ng โดย

#killall syslog-ng
#/usr/local/sbin/syslog-ng

ครับ

ทำการปรับ permission maillog เป็น 644
#chmod 644 /var/log/customer_log/maillog*
แล้วสั่ง รันคำสั่ง ดังนี้
/usr/bin/perl /usr/local/sbin/mailgraph.pl --logfile /var/log/customer-maillog/maillog-smtp0
--daemon-rrd=/var/db/mailgraph/ --ignore-localhost --daemon
--daemon-pid=/var/db/mailgraph/mailgraph2.pid

2189
ต้องการจำกัด user ที่จะเข้าถึงไดเรกทอรี conf



สำหรับ apache ที่ใช้ทดสอบนั้น สามารถสร้างแฟ้มคอนฟิกแยกจาก httpd.conf ได้โดยใส่ในไดเรกทอรี conf.d

ให้สร้างแฟ้ม /etc/httpd/conf.d/my.conf โดยเพิ่มบรรทัดเหล่านี้

<Directory "/var/www/cgi-bin/conf">
Options ExecCGI FollowSymLinks
AllowOverride None
Options None
AuthType Basic
AuthName "Please enter our server's User Account"
AuthUserFile /var/www/users/local_users
Require user user1 user2
Order Allow,Deny
Allow from all
Satisfy all
</Directory>



สร้าง user ดังนี้

ครั้งแรก ใส่ -c เพื่อสร้างไฟล์ ด้วย

htpasswd -c /var/www/users/local_users user1
รอให้ใส่ password ของ user1 ดังนี้

New password:
Re-type new password:
Adding password for user user1
ครั้งต่อไปไม่ต้องใส่ -c

htpasswd /var/www/users/local_users user2



เสร็จแล้วให้ restart httpd ดังนี้

service httpd restart

2190
all application on unix knowledges by golfreeze / set mod rewrite ใน file .htaccess
« on: มกราคม 23, 2011, 12:17:25 am »
ก่อนอื่น ต้องทำความเข้าใจเกี่ยวกับ mod rewrite ก่อน

แต่เด๋วผมมาอัฟเดท อีกที วันนี้ ง่วงๆ เพลียๆ เขียนตัวแปรผิด ตลอด

เอาเป้นว่า config ดังนี้

เปิดไฟล์ httpd.conf ของ apache มาครับ
ถ้าจะใช้ .htaccess ใน dir ก็ config ใน dir นั้นอย่างเดียวน่ะครับ
เช่นจะใช้ ใน document root ที่เป็น /usr/local/www/apache22/data/xxx

ก็ set แบบนี้
<Directory \"/usr/local/www/apache22/data/xxx\">
Options FollowSymLinks
#AllowOverride None จะเลี้ยงใช้ htaccess ไม่ได้ เปลี่ยนเป็น All ครับ
#AllowOveride None
AllowOverride All
Order allow,deny
Allow from all
</Directory>

แล้วไปเขียนไฟล์ test ดังนี้
#vi /usr/local/www/apache22/data/xxx/.htaccess

RewriteEngine on
RewriteBase /
RewriteRules ^(.*)$ index.php?id=$1

-----------------------------------------------------------
#vi index.php
<?php
session_start();
$id = $_GET=[\"id\"];

echo \"$id\";

if (empty($id)) {
echo \"can not use\"; }
else {
echo \"can use\";
}
echo php_uname(\"n\");

?>

แล้วลองเรียกไฟล์ index.php ดูน่ะครับ ถ้าใช้ได้ จะขึ้นเป็น ชื่อ node + can use


golfreeze[at]packetlove.com

Pages: 1 ... 144 145 [146]