วันจันทร์ที่ 12 ธันวาคม พ.ศ. 2554

block เวบด้วย iptables

block เวบด้วย iptable จากท่าน linuxtoy

# vi /etc/rc.d/rc.firewall.local
iptables -t nat -I PREROUTING -p tcp -d facebook.com --dport 80 -j DROP
iptables -t nat -I PREROUTING -p tcp -d facebook.com --dport 443 -j DROP
iptables -t nat -I PREROUTING -p tcp -d facebook.com --dport 445 -j DROP
iptables -t nat -I PREROUTING -p tcp -d www.facebook.com --dport 80 -j DROP
iptables -t nat -I PREROUTING -p tcp -d www.facebook.com --dport 443 -j DROP
iptables -t nat -I PREROUTING -p tcp -d www.facebook.com --dport 445 -j DROP
iptables -I FORWARD -p tcp -d facebook.com --dport 80 -j DROP
iptables -I FORWARD -p tcp -d facebook.com --dport 443 -j DROP
iptables -I FORWARD -p tcp -d facebook.com --dport 445 -j DROP
iptables -I FORWARD -p tcp -d www.facebook.com --dport 80 -j DROP
iptables -I FORWARD -p tcp -d www.facebook.com --dport 443 -j DROP
iptables -I FORWARD -p tcp -d www.facebook.com --dport 445 -j DROP

# vi /etc/rc.local
/sbin/route add -host 66.220.149.18 reject
/sbin/route add -host 69.171.228.1 reject
/sbin/route add -host 69.171.224.13 reject
/sbin/route add -host 69.171.224.14 reject
/sbin/route add -host 69.171.229.11 reject
/sbin/route add -host 69.63.181.15 reject
/sbin/route add -host 69.171.224.12 reject
/sbin/route add -host 69.171.224.11 reject
/sbin/route add -host 66.220.158.11 reject
/sbin/route add -host 69.171.229.11 reject
/sbin/route add -host 66.220.149.11 reject
/sbin/route add -host 69.171.242.11 reject
/sbin/route add -host www.facebook.com reject
/sbin/route add -host facebook.com reject

วันเสาร์ที่ 5 พฤศจิกายน พ.ศ. 2554

หลัก clone freebsd

หลักการทำ Clonning FreeBSD ทุกรุ่น ทำแบบนี้


1. ทำระบบ FreeBSD Server ให้สมบูรณ์ พร้อมใช้งาน Web Server , Authen , FTP ฯลฯ

2. บีบอัดไฟล์ ห้องต่าง ๆ ให้ครบ ดังนี้

ทำการบีบอัดไฟล์ ห้องหลัก ๆ 4 ห้อง คือ /root /boot /etc/ /usr/ /var

จะบีดอัดห้องไหน ให้ไปที่ห้องนั้นก่อน ดังนี้

cd /usr
tar -cvf - * | gzip > /home/usr.tar.gz

อธิบาย ต้องการบีดอัดห้อง /usr ไปไว้ที่ห้อง /home ชื่อไฟล์ usr.tar.gz

จากนั้น ให้ใช้โปรแกรม SSH ดึงไฟล์จากห้อง home ไปไว้ที่เครื่อง xp จะได้ไฟล์แรก คือ usr.tar.gz
ให้ใช้คำสั่ง rm /home/usr.tar.gz เพื่อลบไฟล์ usr.tar.gz ออก ให้มีพื้นที่เหลือไว้ใช้งาน

ทำแบบนี้ให้ครบทุกห้อง จะได้ไฟล์หลัก คือ etc.tar.gz , boot.tar.gz , root.tar.gz , usr.tar.gz , var.tar.gz

จากนั้นเขียนไฟล์ setup.sh ประมาณนี้

#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
echo "#############################################################"
echo " Script Auto Install Authen and Log Server System By FreeBSDAuthen "
echo " www.kroonis.org EasyAuthen Install FreeBSDWeb-All Programs"
echo " E-mail namo_nis@hotmail.com Setup Time 20 -30 Minute "
echo " ############################################################"
mkdir /home/easy
cp /etc/fstab /home/easy/
cp /cdrom/usr.tar.gz /usr/
cp /cdrom/etc.tar.gz /etc/
cp /cdrom/var.tar.gz /var/
cp /cdrom/root.tar.gz /root/
cp /cdrom/boot.tar.gz /boot/

cd /usr/
tar xvf usr.tar.gz
rm -rf usr.tar.gz
cd /etc/
tar xvf etc.tar.gz
rm -rf etc.tar.gz
cd /var/
tar xvf var.tar.gz
rm -rf var.tar.gz
cd /root/
tar xvf root.tar.gz
rm -rf root.tar.gz
cd /boot/
tar xvf boot.tar.gz
rm -rf boot.tar.gz



cp /home/easy/fstab /etc
chmod -R 777 /tmp





ต้องการให้ระบบทำอะไร ก็เขียนคำสั่ง unix ต่อได้เลยทีละบรรทัด


........

echo "Install FreeBSDweb-All & Authen Finish By Manis Slangsingha Thank You "
reboot

เมื่อได้ไฟล์ครบแล้ว ได้แก่ setup.sh , etc.tar.gz , boot.tar.gz , root.tar.gz , usr.tar.gz , var.tar.gz
ให้เขียนไฟล์ทั้งหมดลงแผ่น DVD หรือจะสั่งให้ FreeBSD เขียนไฟล์แบบ ISO ให้ก็ได้

นำระบบไปติดตั้งกับเครื่อง Server ปลายทาง

1. Setup FreeBSD แบบ Express เพื่อให้ Boot ระบบได้

2. เข้าสู่ระบบด้วย root โดยไม่ต้องป้อนรหัสผ่าน

3. ใช้คำสั่ง ติดต่อ CD/DVD ด้วยคำสั่ง

mount /cdrom
cd /cdrom

4. สั่งติดตั้งระบบจากแผ่น DVD ด้วยคำสั่ง

sh setup.sh

เพียงเท่านี้ เราก็จะได้ระบบที่เครื่อง Server ปลายทางแล้ว ใช้เวลาทั้งหมดประมาณ 20-30 นาที

บทความนี้ เขียนขึ้นเพื่อให้สมาชิก FreeBSD สามารถทำแผ่นติดตั้งระบบของตนเองได้ ไว้ใช้งาน

คุณงามความดี เพื่อเฉลิมพระเกียรติพระบาทสมเด็จพระเจ้าอยู่หัว เนื่องในโอกาส พระราชพิธีมหามงคลเฉลิมพระชนมพรรษา ๗ รอบ ๕ ธันวาคม ๒๕๕๔

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

ที่มาจาก : ครูมานิส สลางค์สิงห์ แห่งเว็บไซต์ www.kroonis.org

วันอังคารที่ 1 พฤศจิกายน พ.ศ. 2554

วิธีติดตั้ง DNS บน CENTOS 6.0

เครดิต ท่านโสธร รอดคงที่
yum install bind-chroot
1. chmod 755 /var/named/
2. chmod 775 /var/named/chroot/
3. chmod 775 /var/named/chroot/var/
4. chmod 775 /var/named/chroot/var/named/
5. chmod 775 /var/named/chroot/var/run/
6. chmod 777 /var/named/chroot/var/run/named/
7. cd /var/named/chroot/var/named/
8. ln -s ../../ chroot
cp /usr/share/doc/bind-9.7.0/sample/var/named/named.localhost /var/named/chroot/var/named/
cp /usr/share/doc/bind-9.7.0/sample/var/named/named.ca /var/named/chroot/var/named/
touch /var/named/chroot/etc/named.conf
##สมมุติ
เวบไซต์ http://www.example.intranet
เวบเมล์ http://webmail.example.intranet
phpMyAdmin http://phpmyadmin.example.com
IP 192.168.2.101 client01.example.com
IP 192.168.2.102 client02.example.com
###
###
nano /var/named/chroot/etc/named.conf
##
zone "example.intranet" {
type master;
file "/var/named/chroot/var/named/example.intranet.zone";
};
zone "2.168.192.inaddr.
arpa" {
type master;
file "/var/named/chroot/var/named/192.168.2.zone";
};
##
##
[root@server1 ~]# namedcheckconf
/var/named/chroot/etc/named.conf
/var/named/chroot/etc/named.conf:11: 'mastor' unexpected
ถ้าไม่มีข้อผิดพลาด
[root@server1 ~]# namedcheckconf /var/named/chroot/etc/named.conf
[root@server1 ~]#
nano /var/named/chroot/var/named/example.intranet.zone
## ใส่
$TTL 86400
@ IN SOA exaple.intranet. root.example.intranet. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS ns1
IN MX 10 mail
IN A 192.168.2.111
ns1 IN A 192.168.2.111
webmail IN A 192.168.2.111
www IN A 192.168.2.111
phpmyadmin IN A 192.168.2.111
client01 IN A 192.168.2.101
client02 IN A 192.168.2.102
###
###
nano /var/named/chroot/var/named/192.168.2.zone
##ใส่
$TTL 86400
@ IN SOA exaple.intranet. root.example.intranet. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
NS ns1.example.intranet.
111 PTR ns1.example.intranet.
111 PTR www.example.intranet.
111 PTR webmail.example.intranet.
111 PTR phpmyadmin.example.intranet.
101 PTR client01.example.intranet.
102 PTR client02.example.intranet.
##
##
/etc/init.d/named restart
เสร็จเรียบร้อย อย่าลืมเปลี่ยนชื่อเครื่องให้ถูกต้องด้วยนะครับในไฟล์ /etc/hosts

วันศุกร์ที่ 28 ตุลาคม พ.ศ. 2554

ป้องกัน ssh ด้วย iptables

#Brute Force Protection
iptables -N sshscan
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j sshscan
iptables -A INPUT -p tcp -m tcp --dport 22 --syn -i eth1 -j ACCEPT
iptables -A sshscan -m recent --set --name SSH
iptables -A sshscan -m recent --update --seconds 300 --hitcount 3 --name SSH -j LOG --log-level info --log-prefix "SSH brute force:"
iptables -A sshscan -m recent --update --

วิธีย้าย documentRoot ใน centos

หากเราต้องการย้าย documentroot ใน centos จาก /var/www/html เป็น /home
ต้องเข้าไปแก้ไขในไฟล์ httpd.conf ตรง documentroot /var/www/html เป็น /home
หลังจากนั้นต้องไปปิด selinux /etc/sysconfig/selinux จาก selinux=enforcing เป็น selinux=disabled
"""reboot ก็สามารถทำให้เราสามารถย้าย documentroot ได้อย่างสบายครับ..
หาก add user ไว้แล้วเรียกเวบ http://www.xxx/user ติด permission ลอง chmod 755 ดู ไม่แนะนำนะครับ.แต่กันลืม...

วันอาทิตย์ที่ 23 ตุลาคม พ.ศ. 2554

วิธีติดตั้ง phpmyadmin

ปกติ..หากเราติดตั้ง phpmyadmin แบบดาว์นโหลดมาติดตั้งเอง...บน linux หรือ unix เริ่มต้นโดยการแตกไฟล์
แล้วนำไปไว้ห้อง ducumentroot ของ web Server เช่น /var/www/html/phpmyadmin/ เป็นต้น
หลังจากนั้นให้เข้าไปในห้อง /phpmydmin/libraries หาไฟล์ชื่อ config.default.php ทำการ copy ขึ้นมาไว้ที่ห้อง
/var/www/phpmyadmin/ แล้วทำการเปลี่ยนชื่อไฟล์ เป็น config.inc.php
ทำการแก้ไข config ไฟล์ดังนี้
$cfg['blowfish_secret'] = 'ใส่รหัสความปลอดภัยอะไรก็ได้...';
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'passwordmysql'; ใส่รหัส mysql root
$cfg['Servers'][$i]['auth_type'] = 'http'; เปลี่ยนจาก cookie เป็น http

/**
* MySQL user
*
* @global string $cfg['Servers'][$i]['user']
*/
$cfg['Servers'][$i]['user'] = 'root';

/**
* MySQL password (only needed with 'config' auth_type)
*
* @global string $cfg['Servers'][$i]['password']
*/
$cfg['Servers'][$i]['password'] = 'passwordmysql';

/**

/**
* Database used for Relation, Bookmark and PDF Features
* (see scripts/create_tables.sql)
* - leave blank for no support
* SUGGESTED: 'phpmyadmin'
*
* @global string $cfg['Servers'][$i]['pmadb']
*/
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';

/**
* Bookmark table
* - leave blank for no bookmark support
* SUGGESTED: 'pma_bookmark'
*
* @global string $cfg['Servers'][$i]['bookmarktable']
*/
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';

/**
* table to describe the relation between links (see doc)
* - leave blank for no relation-links support
* SUGGESTED: 'pma_relation'
* @global string $cfg['Servers'][$i]['relation']
*/
$cfg['Servers'][$i]['relation'] = 'pma_relation';

/**
* table to describe the display fields
* - leave blank for no display fields support
* SUGGESTED: 'pma_table_info'
*
* @global string $cfg['Servers'][$i]['table_info']
*/
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';

/**
* table to describe the tables position for the PDF schema
* - leave blank for no PDF schema support
* SUGGESTED: 'pma_table_coords'
*
* @global string $cfg['Servers'][$i]['table_coords']
*/
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';

/**
* table to describe pages of relationpdf
* - leave blank if you don't want to use this
* SUGGESTED: 'pma_pdf_pages'
*
* @global string $cfg['Servers'][$i]['pdf_pages']
*/
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';

/**
* table to store column information
* - leave blank for no column comments/mime types
* SUGGESTED: 'pma_column_info'
*
* @global string $cfg['Servers'][$i]['column_info']
*/
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
/**
* table to store SQL history
* - leave blank for no SQL query history
* SUGGESTED: 'pma_history'
*
* @global string $cfg['Servers'][$i]['history']
*/
$cfg['Servers'][$i]['history'] = 'pma_history';

/**
* table to store the coordinates for Designer
* - leave blank for no Designer feature
* SUGGESTED: 'pma_designer_coords'
*
* @global string $cfg['Servers'][$i]['designer_coords']
*/
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/**
* table to store SQL tracking
* - leave blank for no SQL tracking
* SUGGESTED: 'pma_tracking'
*
* @global string $cfg['Servers'][$i]['tracking']
*/
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';

/**
* table to store user preferences
* - leave blank to disable server storage
* SUGGESTED: 'pma_userconfig'
*
* @global string $cfg['Servers'][$i]['userconfig']
*/
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';

/**
ทำการบันทึกไฟล์ config.inc.php สั่ง chmod 755 ไฟล์ config.inc.php
เข้า http://xx.xxx.xx.xx/phpmyadmin/
ทำการสร้างฐานข้อมูลชื่อ phpmyadmin
สั่ง import script ชื่อ create_table.sql ในไฟล์ที่โหลดมา อยู่ในห้อง /script
แค่นี้ก็จะทำให้ phpmyadmin ไม่มีอะไรแจ้งเตือนให้รำคาณใจอีก..เย้ ๆ ๆ ๆ ๆ
อีกนิดสำหรับเวลาสร้างฐานข้อมูลให้ user แต่ละคน login ด้วยชื่อตัวเอง..แบบไม่มีสิทธิ์สร้างฐานอื่นมีสิทธิ์แค่ฐานข้อมูลตัวเอง..
เข้าในฐานะ root สร้างฐานข้อมูล เสร็จแล้วมาที่ privileges เลือก add user เลือก
Create database with same name and grant all privileges

วันศุกร์ที่ 21 ตุลาคม พ.ศ. 2554

การติดตั้ง mrtg บน cenos

credit"http://www.icez.net/blog/28/%E0%B8%A5%E0%B8%87-mrtg-%E0%B8%9A%E0%B8%99-centosfedora-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86"

yum -y install net-snmp mrtg
wget -4 -O /etc/snmp/snmpd.conf www.icez.net/files/snmpd.conf
wget -4 -O /var/www/mrtg/mrtg-load.sh www.icez.net/files/mrtg-load.sh
chmod a+x /var/www/mrtg/mrtg-load.sh
/etc/init.d/snmpd restart
cfgmaker --global 'WorkDir: /var/www/mrtg' --global 'Options[_]: bits,growright' --output /var/www/mrtg/mrtg.cfg public@localhost
wget -4 -O /tmp/mrtg.cfg www.icez.net/files/mrtg.cfg
cat /tmp/mrtg.cfg >> /var/www/mrtg/mrtg.cfg
/bin/cp -fv /var/www/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg
echo "Alias /mrtg /var/www/mrtg" > /etc/httpd/conf.d/mrtg.conf
/sbin/chkconfig snmpd on
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
/etc/init.d/httpd graceful

วันอังคารที่ 19 กรกฎาคม พ.ศ. 2554

ป้องกันการบุกรุก centos ด้วย denyhosts

บทความจากท่าน voip4share
ใช้ DenyHosts จับตายพวกชอบแอบ Login เข้า CentOS
โดย voip4share » 18 มี.ค. 2010 10:28

เคยลองดูข้อมูลในไฟล์ /var/log/secure มั๊ยครับ ไฟล์นี้จะเก็บข้อมูลทุกอย่างถ้ามีความพยายามจะล๊อกอินเข้าเครื่อง CentOS ด้วย Secure Shell ทั้งล๊อกอินสำเร็จและไม่สำเร็จ ลองดูตัวอย่างข้างล่างนี้ครับ

Mar 17 14:55:46 supercall sshd[4727]: Failed password for root from 218.207.158.7 port 46665 ssh2
Mar 17 14:55:46 supercall sshd[4728]: Received disconnect from 218.207.158.7: 11: Bye Bye
Mar 17 14:55:47 supercall sshd[4729]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.20

จะเห็นว่ามีคนพยายามที่จะล๊อกอินเข้ามาด้วย root มาจาก 218.207.158.7 ด้วย ssh2 ถ้าเราตั้งพาสเวอร์ด root ให้ง่ายต่อการเดาหล่ะก็ เสร็จเขาครับ เขาจะเข้ามาเป็น root และก็จะทำอะไรเครื่อง CentOS ของเราก็ได้ ก็ไม่จำเป็นว่าเขาจะพยายามเข้ามาเป็น root นะครับ เขาอาจจะพยายามล๊อกอินเข้ามาด้วยยูสเซอร์อะไรก็ได้

วิธีป้องกันที่ผมชอบใช้มีอยู่ 2 วิธีครับ คือ ปิดไม่ให้ใช้ root ล๊อกอินเข้าทาง SSH (ใช้ยูสเซอร์อื่นแทน แล้วใช้คำสั่ง su - root เมื่อต้องการเป็น root) และใช้โปรแกรม DenyHosts ล๊อกไอพีต้นทางไว้เลย ถ้าเข้ามาผิดเงื่อนไขก็จะเอาไอพีนั้นไปใส่ไว้ในไฟล์ /etc/hosts.deny ผลก็คือไอพีนั้นจะเข้ามาเครื่องเราไม่ได้อีก เราไม่ต้องทำเองครับโปรแกรม DenyHosts ทำให้

เว็บไซต์โปรแกรม DenyHosts
http://denyhosts.sourceforge.net

วิธีการติดตั้งและใช้งานโปรแกรม DenyHosts
โปรแกรม DenyHosts ใช้ Python ด้วยนะครับ มีให้ดาวน์โหลดทั้งแบบ RPM และ Source Code ถ้าเลือกแบบ RPM ต้องเช็คว่าในเครื่องเราติดตั้ง Python เวอร์ชั่นอะไรแล้วเลือกดาวน์โหลดให้ตรง เช็คเวอร์ชั่น Python

โค้ด: เลือกทั้งหมด
python -V

1. ดาวน์โหลด DenyHosts 2.6
สำหรับ Python 2.3

โค้ด: เลือกทั้งหมด
http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6-python2.3.noarch.rpm?use_mirror=nchc

สำหรับ Python 2.4

โค้ด: เลือกทั้งหมด
wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6-python2.4.noarch.rpm?use_mirror=nchc

สำหรับ Python 2.5

โค้ด: เลือกทั้งหมด
wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6-python2.5.rpm?use_mirror=nchc

และนี่สำหรับท่านที่จะสร้าง RPM เอง

โค้ด: เลือกทั้งหมด
wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6-1.src.rpm?use_mirror=nchc

และถ้าต้องการจะคอมไพล์เอง

โค้ด: เลือกทั้งหมด
wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz?use_mirror=nchc

2. ติดตั้ง DenyHosts
เครื่องผมเป็น Python 2.4

โค้ด: เลือกทั้งหมด
rpm -ivh DenyHosts-2.6-python2.4.noarch.rpm

ไฟล์และไดเร็คตอรี่ที่เกี่ยวข้อง
ไฟล์ /usr/bin/denyhosts.py
ไดเร็คตอรี่ /usr/share/denyhosts

3. สร้างไฟล์คอนฟิก

โค้ด: เลือกทั้งหมด
cd /usr/share/denyhosts
cp denyhosts.cfg-dist denyhosts.cfg

ไฟล์ denyhosts.cfg เป็นไฟล์คอนฟิกของ DenyHosts ครับ รายละเอียดทั้งหมดผมขอยกไว้ไปอยู่ตอนท้ายบทความ

4. ทำให้ DenyHosts ทำงานในโหมด Daemon

โค้ด: เลือกทั้งหมด
cp daemon-control-dist daemon-controlแก้ไขบรรทัดต่อไปนี้ (ถ้าไฟล์เหล่านี้ไม่ได้อยู่ในตำแหน่งดีฟอลท์) ถ้าติดตั้งจาก RPM จะเป็นดีฟอลท์อยู่แล้วครับ จึงไม่ต้องแก้ไขอะไรในไฟล์นี้

DENYHOSTS_BIN = "/usr/bin/denyhosts.py"
DENYHOSTS_LOCK = "/var/lock/subsys/denyhosts"
DENYHOSTS_CFG = "/usr/share/denyhosts/denyhosts.cfg"
PYTHON_BIN = "/usr/bin/env python"

เปลี่ยน Onwer และ Permission

โค้ด: เลือกทั้งหมด
chown root daemon-control
chmod 700 daemon-control


5. ทดสอบรัน DenyHosts แบบ Daemon

โค้ด: เลือกทั้งหมด
./daemon-control start
ถ้ารันได้สำเร็จ จะมีข้อความแบบนี้
starting DenyHosts: /usr/bin/env python /usr/bin/denyhosts.py --daemon --config=/usr/share/denyhosts/denyhosts.cfg
โปรแกรมจะไปดูที่ไฟล์ /var/log/secure และจะเอารายชื่อ IP Address ที่พยายามจะล๊อกอินเข้า CentOS แต่ไม่สำเร็จไปไว้ในไฟล์ /etc/hosts.deny และไฟล์ /usr/share/denyhosts/data/hosts-restricted และจะมีไดเร็คตอรี่ /usr/share/denyhosts/data ถูกสร้างขึ้นมา
แสดงว่าเรารัน DenyHosts แบบ Daemon ได้

6. ทำให้ DenyHosts รันทุกครั้งที่เปิดเครื่อง

โค้ด: เลือกทั้งหมด
cd /etc/init.d
ln -s /usr/share/denyhosts/daemon-control denyhosts
chkconfig --level 35 denyhosts on


มารู้จักกับไฟล์ต่างๆในไดเร็คตอรี่ /usr/share/denyhosts/data และหน้าที่ของมัน
1. ไฟล์ hosts
เป็นรายชื่อ IP Address ที่พยายามล๊อกอินเข้ามาในวันที่และเวลาที่ระบุ ทั้งที่ล๊อกอินสำเร็จและไม่สำเร็จ
66.18.176.160:4:Thu Mar 18 10:20:00 2010
67.52.158.237:265:Thu Mar 18 10:19:59 2010

2. ไฟล์ hosts-restricted
เป็นรายชื่อ IP Address ที่ถูกนำไปใส่ไว้ในไฟล์ /etc/hosts.deny

3. ไฟล์ hosts-root
เป็นรายชื่อ IP Address ที่พยายามจะล๊อกอินเข้ามาด้วย root ดังตัวอย่าง
110.164.66.222:0:Thu Mar 18 10:20:00 2010
112.143.13.139:0:Thu Mar 18 10:19:58 2010
124.127.117.105:13:Thu Mar 18 10:19:58 2010
183.89.134.100:1:Thu Mar 18 10:20:00 2010

4. ไฟล์ hosts-valid
เป็นรายชื่อ IP Address ที่พยายามล๊อกอินเข้ามาด้วยยูสเซอร์ที่มีอยู่ในไฟล์ /etc/passwd รวมทั้งที่ล๊อกอินสำเร็จและไม่สำเร็จ
202.173.222.125:0:Thu Mar 18 10:20:00 2010
203.130.33.50:0:Thu Mar 18 10:20:00 2010
203.179.88.218:0:Thu Mar 18 10:20:00 2010
218.207.158.7:31:Thu Mar 18 10:20:00 2010

5. ไฟล์ offset
บันทึกการสตาร์ทของโปรแกรม sshd
Mar 17 05:25:10 supercall sshd[2842]: Server listening on :: port 22.2068379

6. ไฟล์ suspicious-logins

7. ไฟล์ users-hosts
เป็นรายชื่อยูสเซอร์ที่มีผู้พยายามสุ่มล๊อกอินเข้ามา พร้อมกับ IP Address เป็นยูสเซอร์ที่มีอยู่ในไฟล์ /etc/passwd ตัวอย่าง
mailnull - 67.52.158.237:1:Thu Mar 18 10:19:59 2010
news - 61.19.255.53:1:Thu Mar 18 10:20:00 2010
news - 67.52.158.237:1:Thu Mar 18 10:19:59 2010
nfsnobody - 67.52.158.237:1:Thu Mar 18 10:19:59 2010
nobody - 67.52.158.237:1:Thu Mar 18 10:19:59 2010
operator - 67.52.158.237:1:Thu Mar 18 10:19:59 2010
root - 124.127.117.105:13:Thu Mar 18 10:19:58 2010

8. ไฟล์ users-invalid
เป็นรายชื่อยูสเซอร์ที่มีผู้พยายามสุ่มล๊อกอินเข้ามา เป็นยูสเซอร์ที่ไม่มีอยู่ในระบบ คือไม่มีอยู่ในไฟล์ /etc/passwd ตัวอย่าง
ion:2:Thu Mar 18 10:19:59 2010
iraf:2:Thu Mar 18 10:20:00 2010
irc:2:Thu Mar 18 10:19:59 2010
iresha:2:Thu Mar 18 10:20:00 2010
irina:2:Thu Mar 18 10:19:59 2010

9. ไฟล์ users-valid
เป็นรายชื่อยูสเซอร์ที่มีผู้พยายามสุ่มล๊อกอินเข้ามา เป็นยูสเซอร์ที่มีอยู่ในไฟล์ /etc/passwd ตัวอย่าง
adm:1:Thu Mar 18 10:19:59 2010
apache:2:Thu Mar 18 10:20:00 2010
bin:2:Thu Mar 18 10:20:00 2010
daemon:1:Thu Mar 18 10:19:59 2010
ftp:21:Thu Mar 18 10:20:00 2010

ตัวอย่างข้อมูลในไฟล์ /etc/hosts.deny
ซึ่งถ้า CentOS พบว่า IP Address เหล่านี้พยายามจะใช้ SSH ล๊อกอินเข้ามาไม่ว่าจะด้วยยูสเซอร์อะไรก็ตาม มันจะ Reject ทันที และถ้าเราเปลี่ยนจาก sshd เป็น ALL (ตั้งในไฟล์ denyhosts.cfg ได้) ก็จะเข้าไม่ได้ทุกเซอร์วิสบน CentOS
sshd: 66.18.176.160
sshd: 67.52.158.237
sshd: 203.130.33.50

ไฟล์ allowed-hosts
ไฟล์นี้ดีฟอลท์ไม่มีอยู่ใน DenyHosts นะครับ แต่เราสร้างขึ้นมาได้ ข้อมูลในไฟล์นี้จะเป็น IP Address หรือ Network Address ที่ DenyHosts จะไม่เอาไปไว้ในไฟล์ /etc/hosts.deny ซึ่งหมายความว่าจะล๊อกอินผิดๆยังไงก็ได้ กี่ครั้งก็ได้

โค้ด: เลือกทั้งหมด
vi /usr/share/denyhosts/data/allowed-hosts
192.168.0.*
127.0.0.1
58.59.60.1


ไฟล์ restricted-usernames
ใส่ชื่อยูสเซอร์ที่ DenyHosts จะไม่ยอมให้ล๊อกอินเข้ามาในเครื่องเลย โดยเมื่อ DenyHosts พบว่ามีใครก็ตามที่พยายามล๊อกอินด้วยยูสเซอร์นี้ จะบล๊อก IP เลย

โค้ด: เลือกทั้งหมด
vi /usr/share/denyhosts/data/restricted-usernames

root
mysql
apache


ไฟล์คอนฟิก denyhosts.cfg

############ THESE SETTINGS ARE REQUIRED ############

#
# SECURE_LOG: the log file that contains sshd logging info if you are not sure, grep "sshd:" /var/log/*
#
# The file to process can be overridden with the --file command line argument
#
# Redhat or Fedora Core:
SECURE_LOG = /var/log/secure
#
# Mandrake, FreeBSD or OpenBSD:
#SECURE_LOG = /var/log/auth.log
#
# SuSE:
#SECURE_LOG = /var/log/messages
#
# Mac OS X (v10.4 or greater - also refer to: http://www.denyhosts.net/faq.html#macos
#SECURE_LOG = /private/var/log/asl.log
#
# Mac OS X (v10.3 or earlier):
#SECURE_LOG=/private/var/log/system.log
#

#
# HOSTS_DENY: the file which contains restricted host access information
#
# Most operating systems:
HOSTS_DENY = /etc/hosts.deny
#
# Some BSD (FreeBSD) Unixes:
#HOSTS_DENY = /etc/hosts.allow
#
# Another possibility (also see the next option):
#HOSTS_DENY = /etc/hosts.evil

#
# PURGE_DENY: removed HOSTS_DENY entries that are older than this time when DenyHosts is invoked with the --purge flag
#
# format is: i[dhwmy]
# Where 'i' is an integer (eg. 7)
# 'm' = minutes
# 'h' = hours
# 'd' = days
# 'w' = weeks
# 'y' = years
#
# never purge:
PURGE_DENY =
#
# purge entries older than 1 week
#PURGE_DENY = 1w
#
# purge entries older than 5 days
#PURGE_DENY = 5d

#
# PURGE_THRESHOLD: defines the maximum times a host will be purged. Once this value has been exceeded then this host will not be purged.
# Setting this parameter to 0 (the default) disables this feature.
# default: a denied host can be purged/re-added indefinitely
#PURGE_THRESHOLD = 0
#
# a denied host will be purged at most 2 times.
#PURGE_THRESHOLD = 2
#

#
# BLOCK_SERVICE: the service name that should be blocked in HOSTS_DENY
#
# man 5 hosts_access for details
#
# eg. sshd: 127.0.0.1 # will block sshd logins from 127.0.0.1
#
# To block all services for the offending host:
BLOCK_SERVICE = ALL
# To block only sshd:
#BLOCK_SERVICE = sshd
# To only record the offending host and nothing else (if using an auxilary file to list the hosts). Refer to:
# http://denyhosts.sourceforge.net/faq.html#aux
#BLOCK_SERVICE =
#
#
# DENY_THRESHOLD_INVALID: block each host after the number of failed login attempts has exceeded this value. This value applies to invalid
# user login attempts (eg. non-existent user accounts)
#
DENY_THRESHOLD_INVALID = 5
#

#
# DENY_THRESHOLD_VALID: block each host after the number of failed login attempts has exceeded this value. This value applies to valid
# user login attempts (eg. user accounts that exist in /etc/passwd) except for the "root" user
#
DENY_THRESHOLD_VALID = 10
#

#
# DENY_THRESHOLD_ROOT: block each host after the number of failed login attempts has exceeded this value. This value applies to
# "root" user login attempts only.
#
DENY_THRESHOLD_ROOT = 1
#

#
# DENY_THRESHOLD_RESTRICTED: block each host after the number of failed login attempts has exceeded this value. This value applies to
# usernames that appear in the WORK_DIR/restricted-usernames file only.
#
DENY_THRESHOLD_RESTRICTED = 1
#

#
# WORK_DIR: the path that DenyHosts will use for writing data to (it will be created if it does not already exist).
#
# Note: it is recommended that you use an absolute pathname for this value (eg. /home/foo/denyhosts/data)
#
WORK_DIR = /usr/share/denyhosts/data
#
#
# SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS
#
# SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES|NO
# If set to YES, if a suspicious login attempt results from an allowed-host then it is considered suspicious. If this is NO, then suspicious logins
# from allowed-hosts will not be reported. All suspicious logins from ip addresses that are not in allowed-hosts will always be reported.
#
SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES

#
# HOSTNAME_LOOKUP
#
# HOSTNAME_LOOKUP=YES|NO
# If set to YES, for each IP address that is reported by Denyhosts, the corresponding hostname will be looked up and reported as well (if available).
#
HOSTNAME_LOOKUP=YES
#

#
# LOCK_FILE
#
# LOCK_FILE=/path/denyhosts
# If this file exists when DenyHosts is run, then DenyHosts will exit immediately. Otherwise, this file will be created upon invocation
# and deleted upon exit. This ensures that only one instance is running at a time.
#
# Redhat/Fedora:
LOCK_FILE = /var/lock/subsys/denyhosts
#
# Debian
#LOCK_FILE = /var/run/denyhosts.pid
#
# Misc
#LOCK_FILE = /tmp/denyhosts.lock
#
######################################################################


############ THESE SETTINGS ARE OPTIONAL ############


#######################################################################
#
# ADMIN_EMAIL: if you would like to receive emails regarding newly restricted hosts and suspicious logins, set this address to
# match your email address. If you do not want to receive these reports leave this field blank (or run with the --noemail option)
#
# Multiple email addresses can be delimited by a comma, eg:
# ADMIN_EMAIL = foo@bar.com, bar@foo.com, etc@foobar.com
#
ADMIN_EMAIL = alert@voip4share.com
#

#
# SMTP_HOST and SMTP_PORT: if DenyHosts is configured to email reports (see ADMIN_EMAIL) then these settings specify the
# email server address (SMTP_HOST) and the server port (SMTP_PORT)
#
SMTP_HOST = localhost
SMTP_PORT = 25
#

#
# SMTP_USERNAME and SMTP_PASSWORD: set these parameters if your
# smtp email server requires authentication
#
#SMTP_USERNAME=foo
#SMTP_PASSWORD=bar
#

#
# SMTP_FROM: you can specify the "From:" address in messages sent from DenyHosts when it reports thwarted abuse attempts
#
SMTP_FROM = DenyHosts
#

#
# SMTP_SUBJECT: you can specify the "Subject:" of messages sent by DenyHosts when it reports thwarted abuse attempts
SMTP_SUBJECT = DenyHosts Report on 192.168.4.55
#

#
# SMTP_DATE_FORMAT: specifies the format used for the "Date:" header when sending email messages.
#
# for possible values for this parameter refer to: man strftime
#
# the default:
#
#SMTP_DATE_FORMAT = %a, %d %b %Y %H:%M:%S %z
#

#
# SYSLOG_REPORT
#
# SYSLOG_REPORT=YES|NO
# If set to yes, when denied hosts are recorded the report data will be sent to syslog (syslog must be present on your system).
# The default is: NO
#
#SYSLOG_REPORT=NO
#
#SYSLOG_REPORT=YES
#

#
# ALLOWED_HOSTS_HOSTNAME_LOOKUP
#
# ALLOWED_HOSTS_HOSTNAME_LOOKUP=YES|NO
# If set to YES, for each entry in the WORK_DIR/allowed-hosts file, the hostname will be looked up. If your versions of tcp_wrappers
# and sshd sometimes log hostnames in addition to ip addresses then you may wish to specify this option.
#
#ALLOWED_HOSTS_HOSTNAME_LOOKUP=NO
#

#
# AGE_RESET_VALID: Specifies the period of time between failed login attempts that, when exceeded will result in the failed count for
# this host to be reset to 0. This value applies to login attempts to all valid users (those within /etc/passwd) with the
# exception of root. If not defined, this count will never be reset.
#
# See the comments in the PURGE_DENY section (above) for details on specifying this value or for complete details
# refer to: http://denyhosts.sourceforge.net/faq.html#timespec
#
AGE_RESET_VALID=5d
#

#
# AGE_RESET_ROOT: Specifies the period of time between failed login attempts that, when exceeded will result in the failed count for
# this host to be reset to 0. This value applies to all login attempts to the "root" user account. If not defined,
# this count will never be reset.
#
# See the comments in the PURGE_DENY section (above) for details on specifying this value or for complete details
# refer to: http://denyhosts.sourceforge.net/faq.html#timespec
#
AGE_RESET_ROOT=25d
#

#
# AGE_RESET_RESTRICTED: Specifies the period of time between failed login attempts that, when exceeded will result in the failed count for
# this host to be reset to 0. This value applies to all login attempts to entries found in the WORK_DIR/restricted-usernames file.
# If not defined, the count will never be reset.
#
# See the comments in the PURGE_DENY section (above) for details on specifying this value or for complete details
# refer to: http://denyhosts.sourceforge.net/faq.html#timespec
#
AGE_RESET_RESTRICTED=25d
#
#
# AGE_RESET_INVALID: Specifies the period of time between failed login attempts that, when exceeded will result in the failed count for
# this host to be reset to 0. This value applies to login attempts made to any invalid username (those that do not appear
# in /etc/passwd). If not defined, count will never be reset.
#
# See the comments in the PURGE_DENY section (above) for details on specifying this value or for complete details
# refer to: http://denyhosts.sourceforge.net/faq.html#timespec
#
AGE_RESET_INVALID=10d
#

#
# RESET_ON_SUCCESS: If this parameter is set to "yes" then the failed count for the respective ip address will be reset to 0
# if the login is successful.
#
# The default is RESET_ON_SUCCESS = no
#
#RESET_ON_SUCCESS = yes
#

#
# PLUGIN_DENY: If set, this value should point to an executable program that will be invoked when a host is added to the
# HOSTS_DENY file. This executable will be passed the host that will be added as it's only argument.
#
#PLUGIN_DENY=/usr/bin/true
#

#
# PLUGIN_PURGE: If set, this value should point to an executable program that will be invoked when a host is removed from the
# HOSTS_DENY file. This executable will be passed the host that is to be purged as it's only argument.
#
#PLUGIN_PURGE=/usr/bin/true
#

#
# USERDEF_FAILED_ENTRY_REGEX: if set, this value should contain a regular expression that can be used to identify additional
# hackers for your particular ssh configuration. This functionality extends the built-in regular expressions that DenyHosts uses.
# This parameter can be specified multiple times.
# See this faq entry for more details: http://denyhosts.sf.net/faq.html#userdef_regex
#
#USERDEF_FAILED_ENTRY_REGEX=
#

######### THESE SETTINGS ARE SPECIFIC TO DAEMON MODE ##########

#
# DAEMON_LOG: when DenyHosts is run in daemon mode (--daemon flag) this is the logfile that DenyHosts uses to report it's status.
# To disable logging, leave blank. (default is: /var/log/denyhosts)
#
DAEMON_LOG = /var/log/denyhosts
#
# disable logging:
#DAEMON_LOG =
#

#
# DAEMON_LOG_TIME_FORMAT: when DenyHosts is run in daemon mode (--daemon flag) this specifies the timestamp format of
# the DAEMON_LOG messages (default is the ISO8061 format: ie. 2005-07-22 10:38:01,745)
#
# for possible values for this parameter refer to: man strftime
#
# Jan 1 13:05:59
#DAEMON_LOG_TIME_FORMAT = %b %d %H:%M:%S
#
# Jan 1 01:05:59
#DAEMON_LOG_TIME_FORMAT = %b %d %I:%M:%S
#

#
# DAEMON_LOG_MESSAGE_FORMAT: when DenyHosts is run in daemon mode (--daemon flag) this specifies the message format of each logged
# entry. By default the following format is used:
#
# %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s
#
# Where the "%(asctime)s" portion is expanded to the format defined by DAEMON_LOG_TIME_FORMAT
#
# This string is passed to python's logging.Formatter contstuctor. For details on the possible format types please refer to:
# http://docs.python.org/lib/node357.html
#
# This is the default:
#DAEMON_LOG_MESSAGE_FORMAT = %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s
#

#
# DAEMON_SLEEP: when DenyHosts is run in daemon mode (--daemon flag) this is the amount of time DenyHosts will sleep between polling
# the SECURE_LOG. See the comments in the PURGE_DENY section (above) for details on specifying this value or for complete details
# refer to: http://denyhosts.sourceforge.net/faq.html#timespec
#
#
DAEMON_SLEEP = 30s
#

#
# DAEMON_PURGE: How often should DenyHosts, when run in daemon mode, run the purge mechanism to expire old entries in HOSTS_DENY
# This has no effect if PURGE_DENY is blank.
#
DAEMON_PURGE = 1h
#

######### THESE SETTINGS ARE SPECIFIC TO ##########
######### DAEMON SYNCHRONIZATION ##########

#
# Synchronization mode allows the DenyHosts daemon the ability to periodically send and receive denied host data such that
# DenyHosts daemons worldwide can automatically inform one another regarding banned hosts. This mode is disabled by
# default, you must uncomment SYNC_SERVER to enable this mode.
#
# for more information, please refer to: http:/denyhosts.sourceforge.net/faq.html#sync
#

# SYNC_SERVER: The central server that communicates with DenyHost daemons. Currently, denyhosts.net is the only available server
# however, in the future, it may be possible for organizations to install their own server for internal network synchronization
#
# To disable synchronization (the default), do nothing.
#
# To enable synchronization, you must uncomment the following line:
#SYNC_SERVER = http://xmlrpc.denyhosts.net:9911
#

#
# SYNC_INTERVAL: the interval of time to perform synchronizations if SYNC_SERVER has been uncommented. The default is 1 hour.
#
#SYNC_INTERVAL = 1h
#

#
# SYNC_UPLOAD: allow your DenyHosts daemon to transmit hosts that have been denied? This option only applies if SYNC_SERVER has
# been uncommented. The default is SYNC_UPLOAD = yes
#
#SYNC_UPLOAD = no
#SYNC_UPLOAD = yes
#

#
# SYNC_DOWNLOAD: allow your DenyHosts daemon to receive hosts that have been denied by others? This option only applies if SYNC_SERVER
# has been uncommented. The default is SYNC_DOWNLOAD = yes
#
#SYNC_DOWNLOAD = no
#SYNC_DOWNLOAD = yes
#

#
# SYNC_DOWNLOAD_THRESHOLD: If SYNC_DOWNLOAD is enabled this parameter filters the returned hosts to those that have been blocked this many
# times by others. That is, if set to 1, then if a single DenyHosts server has denied an ip address then you will receive the denied host.
#
# See also SYNC_DOWNLOAD_RESILIENCY
#
#SYNC_DOWNLOAD_THRESHOLD = 10
#
# The default is SYNC_DOWNLOAD_THRESHOLD = 3
#
#SYNC_DOWNLOAD_THRESHOLD = 3
#

#
# SYNC_DOWNLOAD_RESILIENCY: If SYNC_DOWNLOAD is enabled then the value specified for this option limits the downloaded data
# to this resiliency period or greater.
#
# Resiliency is defined as the timespan between a hackers first known attack and it's most recent attack. Example:
#
# If the centralized denyhosts.net server records an attack at 2 PM and then again at 5 PM, specifying a SYNC_DOWNLOAD_RESILIENCY = 4h
# will not download this ip address.
#
# However, if the attacker is recorded again at 6:15 PM then the ip address will be downloaded by your DenyHosts instance.
#
# This value is used in conjunction with the SYNC_DOWNLOAD_THRESHOLD and only hosts that satisfy both values will be downloaded.
# This value has no effect if SYNC_DOWNLOAD_THRESHOLD = 1
#
# The default is SYNC_DOWNLOAD_RESILIENCY = 5h (5 hours)
#
# Only obtain hackers that have been at it for 2 days or more:
#SYNC_DOWNLOAD_RESILIENCY = 2d
#
# Only obtain hackers that have been at it for 5 hours or more:
#SYNC_DOWNLOAD_RESILIENCY = 5h
#

เทคนิคการลบ IP Address ที่ถูก Block
ถ้าจะลบ IP ที่ถูกบล๊อกออก ต้องลบออกจากหลายไฟล์ครับ เพื่อไม่ให้มันกลับมาอยู่ใน /etc/hosts.deny อีกแม้ว่าจะล๊อกอินถูกแล้วก็ตาม
1. หยุดการทำงานของ DenyHosts

โค้ด: เลือกทั้งหมด
service denyhosts stop
2. ลบบรรทัด IP Address นั้นออกจากไฟล์ /etc/hosts.deny
3. ลบบรรทัด IP Address นั้นออกจากไฟล์ /usr/share/denyhosts/data/hosts
4. ลบบรรทัด IP Address นั้นออกจากไฟล์ /usr/share/denyhosts/data/hosts-restricted
5. ลบบรรทัด IP Address นั้นออกจากไฟล์ /usr/share/denyhosts/data/hosts-root
6. ลบบรรทัด IP Address นั้นออกจากไฟล์ /usr/share/denyhosts/data/hosts-valid
7. ลบบรรทัด IP Address นั้นออกจากไฟล์ /usr/share/denyhosts/data/user-hosts
8. (ออปชั่น) เพิ่ม IP Address นั้นในไฟล์ /usr/share/denyhosts/data/allowed-hosts
9. สตาร์ท DenyHosts

โค้ด: เลือกทั้งหมด
service denyhosts startvoip4share
Administrator

โพสต์: 689
ลงทะเบียนเมื่อ: 18 พ.ย. 2009 11:26
ที่อยู่: รามคำแหง กรุงเทพฯ
เว็บไซต์ ข้างบน
--------------------------------------------------------------------------------
ตอบกระทู้1 โพสต์ • หน้า 1 จากทั้งหมด 1

ย้อนกลับไปยัง CentOS - The Community Enterprise Operating System
ไปที่: เลือกบอร์ด ------------------ ประกาศจากเว็บบอร์ด การสมัครสมาชิกเว็บบอร์ด พื้นฐานเกี่ยวกับ VoIP Elastix - Unified Communications Software Asterisk SIP Server PHPAGI - Where PHP Connects To Asterisk A2Billing - Calling Card & Billing Application CentOS - The Community Enterprise Operating System AstBill - Billing, Routing and Management for Asterisk and VoIP VOS3000 - SIP/H.323 High Performance Soft Switch OpenSIPS - Reliable and High-Performance SIP Server คุณสมบัติของโปรแกรม VoipSwitch - Affordable Communication Solutions สินค้ารุ่นใหม่ Gateway / ATA / WiFi ATA IP PBX GSM VoIP ผลิตภัณฑ์รุ่นใหม่ สินค้ารุ่นใหม่ สินค้ารุ่นใหม่ IP Phone Gateway / ATA สินค้ารุ่นใหม่ สินค้ารุ่นใหม่ SoftPhone โปรแกรมบน Windows โปรแกรมบน Mac OS โปรแกรมบน Linux โปรแกรมบน Symbian OS โปรแกรมบน Windows Mobile โปรแกรมบน Smartphone โปรแกรมบน Android ซื้อ-ขาย-แลกเปลี่ยน ตัวแทนจำหน่ายสินค้า กระทู้ทั่วไป - ฝากคำถาม ข่าวน่าสนใจ - งานประชาสัมพันธ์
ผู้ใช้งานขณะนี้
กำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และ บุคคลทั่วไป 3 ท่าน

หน้าเว็บบอร์ด ทีมงาน • ลบ Cookies • ไทม์โซน GMT + 7 ชั่วโมง

© 2009 VoIP4Share
ภาษาไทยโดย Mindphp.com และ phpBBThailand.com
phpBB SEO

วันอาทิตย์ที่ 12 มิถุนายน พ.ศ. 2554

tip การรักษาความปลอดภัยบน centos

Tip : การรักษาความปลอดภัย โดยปิด Service ที่ไม่ได้ใช้งาน บน CentOS สำหรับ Gateway อย่างเดียว
จากท่าน ton-or""""
Ton-Or — 26 September, 2009 - 11:41
กรณีที่เราไม่ได้ใช้งานด้านอื่นๆ เช่น mail server เน้นนำมาใช้เป็น gateway ต่อ ADSL ของเราอย่างเดียวนั้น Srevice หลายๆตัวที่ run อยู่ ไม่จำเป็นต้องใช้มาปิด Service พวกนั้นกัน
ตรวจสอบ Service ทั้งหมดที่เปิดอยู่ก่อน
chkconfig –list | grep on
จะได้ประมาณนี้
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
messagebus 0:off 1:off 2:off 3:on 4:on 5:on 6:off
smartd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
irqbalance 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcgssd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
isdn 0:off 1:off 2:on 3:on 4:on 5:on 6:off
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
acpid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
microcode_ctl 0:off 1:off 2:on 3:on 4:on 5:on 6:off
pcmcia 0:off 1:off 2:on 3:on 4:on 5:on 6:off
cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcidmapd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
readahead_early 0:off 1:off 2:off 3:off 4:off 5:on 6:off
readahead 0:off 1:off 2:off 3:off 4:off 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rawdevices 0:off 1:off 2:off 3:on 4:on 5:on 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
ลอกเขามาเลยแล้วกัน

/sbin/chkconfig --level 0123456 portmap off
/sbin/chkconfig --level 0123456 nfslock off
/sbin/chkconfig --level 0123456 netfs off
/sbin/chkconfig --level 0123456 rpcgssd off
/sbin/chkconfig --level 0123456 rpcidmapd off
/sbin/chkconfig --level 0123456 autofs off
/sbin/chkconfig --level 0123456 sendmail off
/sbin/chkconfig --level 0123456 cups off
/sbin/chkconfig --level 0123456 xfs off
/sbin/chkconfig --level 0123456 isdn off
/sbin/chkconfig --level 0123456 pcmcia off

อ้างอิง
http://prefetch.net/blog/index.php/2006/12/27/securing-centos-installations-by-disabling-unneeded-services/
linux - cafedevel - News
1910 reads

วันอาทิตย์ที่ 3 เมษายน พ.ศ. 2554

เข้าหน้า login ต้องคลิ๊กหลายครั้งวิธีแก้ไข

แก้ปัญหา user ต้อง Login 2 ครั้งจึงจะเข้าสู่ระบบได้

พบคำตอบแล้วครับ ปัญหา user ต้อง Login 2 ครั้งจึงเข้าสู่ระบบได้ เป็นที่ไฟล์ radiusd.conf ศึกษาวิธีแก้ปัญหาจากบทความนี้

# nano /etc/raddb/radiusd.conf

กดปุ่ม Ctrl + w แล้วพิมพ์ cleanup_delay = 5 กดปุ่ม Enter

โปรแกรมจะวิ่งไปที่บรรทัด cleanup_deay = 5 ให้แก้ไขใหม่เป็น cleanup_deay = 0

บันทึกไฟล์ กดปุ่ม Ctrl + o ตามด้วยปุ่ม Enter ออกจากการแก้ไข กดปุ่ม Ctrl + x

สั่งให้ radiusd ทำงานใหม่ด้วยคำสั่ง

# /etc/init.d/radiusd restart
หรือ
# service radiusd restart

แหล่งข้อมูลจาก
http://www.kroonis.org/index.php?name=authen&file=readauthen&id=13

วันเสาร์ที่ 26 กุมภาพันธ์ พ.ศ. 2554

กรณี error เกี่ยวกับ auto tool ทุกตัว

In /usr/ports/www/apache22/Makefile, replace

Code:
USE_AUTOTOOLS= autoconf:267 libtool:22with

Code:
USE_AUTOTOOLS= autoconf libtool

ตัวโปรแกรมอื่น ๆ เช่นกันเช่น proftp หรือ php5

วันศุกร์ที่ 25 กุมภาพันธ์ พ.ศ. 2554

วิธีโม squid จากเวบ linuxthai

บทความจากเวบ linuxthai.org/forum คุณFAK-MUW
http_port 3128 transparent no-connection-auth
tcp_outgoing_address 0.0.0.0
udp_incoming_address 0.0.0.0
udp_outgoing_address 0.0.0.0
icp_port 0

# Time Out
request_timeout 5 minutes
forward_timeout 5 minutes
connect_timeout 5 minutes
peer_connect_timeout 1 minutes
pconn_timeout 120 seconds
read_timeout 15 minutes
request_timeout 5 minutes
persistent_request_timeout 2 minute
shutdown_lifetime 5 seconds
negative_ttl 2 minutes
negative_ttl 3 minutes
positive_dns_ttl 120 seconds
negative_dns_ttl 120 seconds

netdb_low 900
netdb_high 1000
client_db on
client_lifetime 1 day

# mark for no cache
hierarchy_stoplist cgi-bin ? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ patch_lv1
acl QUERY urlpath_regex cgi-bin \? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini .exe localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ updatelist$ patch_lv1
cache deny QUERY

# OPTIONS WHICH AFFECT THE CACHE SIZE
# -----------------------------------
#---- ËÒÃ 3
cache_mem 1536 MB
cache_swap_low 90
cache_swap_high 95
memory_pools on
memory_pools_limit 512 MB

maximum_object_size 256 MB
maximum_object_size_in_memory 1024 KB

ipcache_size 4096
ipcache_low 90
ipcache_high 95
fqdncache_size 4096

cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF

# LOGFILE
# -------------------------------------
#cache_dir aufs /data/squid 20480 24 256
cache_dir ufs /var/spool/squid 9000 16 256

cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none
# mime_table /usr/share/squid/mime.conf
pid_filename /var/run/squid.pid

log_fqdn off
client_netmask 255.255.255.255
ftp_passive on
ftp_sanitycheck on
#DNS ¢Í§SERVER
dns_nameservers 127.0.0.1 203.146.237.237 203.146.237.222

# OPTIONS FOR TUNING THE CACHE
# --------------------------------------
# refresh_pattern ^ftp: 10080 95% 241920 reload-into-ims override-lastmod
# refresh_pattern . 180 95% 120960 reload-into-ims override-lastmod

refresh_pattern -i \.*$ 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload

refresh_pattern -i ^https://*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://www.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://www.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.gg.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload

refresh_pattern -i ^http://*.*.*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload

refresh_pattern -i .(gif|tif|tiff|jpeg|xbm|png|wrl|ico|pnm|pbm|pgm|ppm|rgb|xpm|xwd|pic|pict|bmp|jpg|jpe)$ 0 25000% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(arj|sit|zip|rar|rgz|cfg|rtf|psf|hqx|exe|lzh|lha|cab|tar|tgz|gz|Z|wp|wp5|ps|prn|srf|pdf|tex|latax|txt|doc|ppt|gpf|upd|iso|jar|bz2|uue|gzip|ace|cab|kf|a[0-9][0-9]|r[0-9][0-9])$ 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(midi|wav|aif|aiff|au|ram|ra|snd|mid|mp2|mp3|mp4|mov|mpg|mpeg|mpe|avi|qt|qtm|viv)$ 0 120% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(swf)$ 525960 18000% 525960 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320 reload-into-ims
refresh_pattern -i \\.flv$ 10080 90% 999999 ignore-no-cache override-expire ignore-private

quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100

half_closed_clients off

# ACL CONTROLS
# ---------------------------------------------------------------
acl virus_nimda urlpath_regex -i .*/system32/cmd\.exe.*
acl virus_nimda2 urlpath_regex -i .*/winnt/system32/cmd.exe.*
acl virus_nimda2 urlpath_regex -i .*/MSADC/root.exe..c.dir$
acl virus_nimda2 urlpath_regex -i .*/scripts/root.exe..c.dir$
acl virus_nimda2 urlpath_regex -i .*/appie.exe
acl virus_nimda2 urlpath_regex -i .*/app.exe

acl Manager proto cache_object
acl all src 0.0.0.0/0
acl localhost src 127.0.0.1/32
acl our_networks src 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
acl All_Port port 1-65535
acl CONNECT method CONNECT
acl blockweb dst 208.73.212.0/24

acl bitword urlpath_regex \.torrent\*?$
acl bittorrent_announce url_regex -i http://.+announce.+info_hash= #announce.php?passkey

##############################
# Limited file download < 128 MB ´ÒǹìâËÅ´äÁèà¡Ô¹ 128 M
# reply_body_max_size SizeInByte deny|allow acl
reply_body_max_size 134217728 deny our_networks
request_body_max_size 128 MB
##############################

http_access deny virus_nimda
http_access deny virus_nimda2
http_access deny bitword
http_access deny bittorrent_announce
http_access deny blockweb

http_access allow Manager all
http_access deny Manager
http_access allow All_Port
http_access allow CONNECT All_Port
http_access allow localhost
http_access allow our_networks
http_access deny all

http_reply_access allow all
icp_access allow all

# ADMINISTRATIVE PARAMETERS
# ------------------------------

cache_mgr squid@localhost
visible_hostname cache.hadyaiinternet.com

# MISCELLANEOUS
# -------------------------------
logfile_rotate 3
log_icp_queries off
query_icmp off
buffered_logs off
reload_into_ims on
nonhierarchical_direct off
prefer_direct on
strip_query_terms off
pipeline_prefetch on
ie_refresh on
forwarded_for on
vary_ignore_expire on
store_dir_select_algorithm round-robin
ignore_unknown_nameservers on

header_access Allow allow all
header_access Authorization allow all
header_access Cache-Control allow all
header_access Content-Encoding allow all
header_access Content-Length allow all
header_access Content-Type allow all
header_access Date allow all
header_access Expires allow all
header_access Host allow all
header_access If-Modified-Since allow all
header_access Last-Modified allow all
header_access Location allow all
header_access Pragma allow all
header_access Accept allow all
header_access Accept-Charset allow all
header_access Accept-Encoding allow all
header_access Accept-Language allow all
header_access Content-Language allow all
header_access Mime-Version allow all
header_access Retry-After allow all
header_access Title allow all
header_access Connection allow all
header_access Proxy-Connection allow all
header_access All allow all

อบรม advance network




23 - 24 กุมภาพันธ์ 2554 ไปอบรมเรื่องการวิเคราะห์เครือข่ายขั้นสูง ใช้ packet tracer cisco อบรมสนุกดี..แต่อบรมเวลาน้อยไปหน่อย..เสียดายวิทยากรเก่ง ๆ กำลังมัน...จบซะแล้ว..