วันพฤหัสบดีที่ 19 มิถุนายน พ.ศ. 2557

ubuntu 12.04 clear cache squid

script Clear Cache on Ubuntu12.04LTS
#cd /root
#nano clear-squid.sh
เพิ่มคำสั่งเหล่านี้เข้าไป
#!/bin/sh
/etc/init.d/squid3 stop
cd /var/spool/squid3/
rm -Rf *
squid3 -z
/etc/init.d/squid3 start
echo “Finish Of Clear Squid Cache”
จากนั้นกด Ctrl+o (โอ)
Enter
Ctrl+x

เข้าไปที่ /root
#cd /root
#sh clear-squid.sh
ตั้งค่า crontab ให้คลียร์ cache เอง
#crontab -e
เพิ่มคำสั่งต่อไปนี้
PATH=/usr/sbin:/usr/bin:/sbin:/bin:/root
00 12 * * * /root/clear-squid.sh
จากนั้นกด Ctrl+o (โอ)
Enter
Ctrl+x
———————————————————————————————–
หมายเหตุ สามารถปรับแต่งได้ตามความเหมาะสม
เครดิต..blog ครูชาตรีออนไลน์ HS3VZF ^_^

วันศุกร์ที่ 16 พฤษภาคม พ.ศ. 2557

การค้นหาคำใน file linux

ค้นหาจากหลายๆ ไฟล์
บางครั้งมีหลายไฟล์ที่เราต้องการค้นหานั้น ก็สามารถทำได้โดยระบุชื่อไฟล์เป็น * ได้

เช่นค้นหาคำว่า root จากทุกไฟล์ใน /etc/

$ grep -r root /etc/*

วันศุกร์ที่ 25 เมษายน พ.ศ. 2557

script สำหรับเช็ค freeradius stop แล้วให้ start

สอบถาม shell script ตั้งเวลาใน crontab ไม่ได้ครับ..ตั้งชื่อไฟล์ไว้ที่ /root/freeradius.sh สั่ง chmod +x แล้ว
#!/bin/sh
##### freeradius check ######
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if pgrep freeradius 2>&1 >/dev/null;then echo ok;else /etc/init.d/freeradius start;fi
##
##
##
ตั้งเวลาใน crontab มันไม่ทำงานนะครับ log มันขึ้นอย่างนี้นะครับ
Apr 25 15:53:01 pyo1 CRON[27691]: (root) CMD (/bin/sh /root/freeradius.sh)
Apr 25 15:53:01 pyo1 CRON[27688]: (CRON) info (No MTA installed, discarding output)
แสดงว่า cron ทำงานแต่ในไฟล์ script มันมีอะไรผิดพลาด หาจนตาลายหมดแล้วครับ..ไม่รู้เกิดอะไรขึ้น..

แต่เวลาผมสั่ง #sh /root/freeradius.sh ไฟล์ script ดังกล่าวสามารถทำงานได้ปกตินะครับ...แสดง echo OK ได้ปกติ


ผู้ตอบ....Keigo Thaiadmin VIP

Script ทำงานปกติครับ

โดยปกติแล้ว cron จะ email terminal output แต่เครื่องของคุณตอนนี้ไม่ได้ติดตั้ง MTA ไว้ (postfix/sendmail) ทำให้ cron ส่ง output ออกไปไม่ได้

ถ้าไม่อยากติดตั้ง MTA แต่มี GUI อาจจะใช้ notify-send

*/30 * * * * DISPLAY=:0 notify-send "$(/bin/sh /root/freeradius.sh)"

ถ้าไม่งั้นลอง redirect output ออก terminal เลยก็ได้ครับ เช่น

# tty
/dev/pts/

*/30 * * * * /bin/sh /root/freeradius.sh > /dev/pts/0

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

logrotage

บทความจาก linuxthai
สร้างไฟล์ไว้ที่ home ก่อนครับ
cd /home
mkdir makelog
cd /home/makelog
touch makelog.sh
cd ..
chmod 755 -R makelog

เอาไฟล์นี้ไปใส่ใน makelog.sh
##### Save Squid Log ######
timeaccess=`date +%Y-%m-%d`
LIMIT=90
cp -Rf /var/log/squid/access.log /home/makelog/$timeaccess-access.log
chmod 777 /home/makelog/$timeaccess-access.log
gzip /home/makelog/$timeaccess-access.log
md5sum /home/makelog/$timeaccess-access.log.gz > /home/makelog/$timeaccess-access.log.gz.md5sum
cp -Rf /var/log/squid/store.log /home/makelog/$timeaccess-store.log
chmod 777 /home/makelog/$timeaccess-store.log
gzip /home/makelog/$timeaccess-store.log
md5sum /home/makelog/$timeaccess-store.log.gz > /home/makelog/$timeaccess-store.log.gz.md5sum
find /home/makelog/ -maxdepth 1 -type f \( -ctime $LIMIT \) -print \-exec rm {} \; > /dev/null

แล้วก็ไปที่ crontab -e
59 23 * * * root sh /home/makelog/makelog.sh


หรือทดสอบ sh /home/makelog/makelog.sh

แก้ไข...สำหรับ ubuntu 12.04 โดยอ.ธนากร แห่งพิษณุโลก
#!/bin/sh
##### Save Squid Log ######
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
timeaccess=`date +%Y-%m-%d`
LIMIT=90
cd /var/log/airlink/squidlog/ อย่าลืมใส่ตรงนี้ด้วย...ไม่งั้นมันไม่รัน....
cp -Rf /var/log/squid3/access.log /var/log/airlink/squidlog/$timeaccess-access.log
chmod 777 /var/log/airlink/squidlog/$timeaccess-access.log
gzip /var/log/airlink/squidlog/$timeaccess-access.log
md5sum /var/log/airlink/squidlog/$timeaccess-access.log.gz > /var/log/airlink/squidlog/$timeaccess-access.log.gz.md5sum
#cp -Rf /var/log/squid3/store.log /var/log/airlink/squidlog/$timeaccess-store.log
#chmod 777 /var/log/airlink/squidlog/$timeaccess-store.log
#gzip /var/log/airlink/squidlog/$timeaccess-store.log
#md5sum /var/log/airlink/squidlog/$timeaccess-store.log.gz > /var/log/airlink/squidlog/$timeaccess-store.log.gz.md5sum
find /var/log/airlink/squidlog/ -maxdepth 1 -type f \( -ctime $LIMIT \) -print \-exec rm {} \; > /dev/null





mrtg on centos 6.x

บทความจากเวบ hostpro.com
วันนี้ทาง Host4PRO จะมานำเสนอวิธีการติดตั้ง MRTG บนระบบปฏิบัติการ CentOS 6.x ที่ติดตั้ง Directadmin

ประโยชน์:
-เพื่อดูสิถิติการใช้งานเครื่องไม่ว่าจะเป็น CPU , RAM , Network และอื่นๆ

วิธีการติดตั้ง
ขั้นที่ 1 Copy ไปวางเลยครับ

yum -y remove net-snmp mrtg ; wget -qO - http://www.thzhost.com/files/mrtg.sh | sh
ขั้นที่ 2 Copy ไปวางครับ

yum -y install net-snmp net-snmp-utils mrtg mrtg-libs
ขั้นที่ 3 ทดสอบการติดตั้ง snmp copy ไปวางเช่นกันครับ

snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
ผลลัพธ์จะเป็นดังนี้
IP-MIB::ipAdEntIfIndex.103.xxx.xx.xx= INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

ท่านจะสามารถเข้าดู MRTG ได้จาก http://ip/mrtg นะครับ

วันเสาร์ที่ 28 กันยายน พ.ศ. 2556

squid 3 บน centos 5.x

บทความจากเวบไซด์..
http://www.howtoforge.com/anonymous-proxy-using-squid-3-centos-5.x

1) Installation Of Squid 3:
CentOS 5 comes with Squid 2.6 but we need Squid 3, so we will download the source rpm of squid 3 and compile it for our OS.



1.1) Install Prerequisites
Install pre-requisite software, i.e. development tools to get all the compilers, libraries and other rpms for the compilation of SQUID 3.

yum -y groupinstall "Development Tools"
yum -y install rpm-build openjade linuxdoc-tools openldap-devel pam-devel openssl-devel httpd rpm-devel



1.2) Download Squid 3 Source RPM
Download source rpm of Squid 3 from the FEDORA website and install it.

cd /usr/src
wget http://download.fedora.redhat.com/pub/fedora/linux/releases/10/Fedora/source/SRPMS/squid-3.0.STABLE10-1.fc10.src.rpm
rpm -ivh squid-3.0.STABLE10-1.fc10.src.rpm



1.3) Compile Squid 3
Use the following commands to start the compilation, at the end it will generate an rpm file to install:

cd /usr/src/redhat/SPECS
rpmbuild -bb squid.spec



1.4) Install Squid 3
Install the newly built rpm, which will be found in /usr/src/redhat/RPMS/i386 for i686 and /usr/src/redhat/RPMS/x86_64 for x86_64.

rpm -Uvh /usr/src/redhat/RPMS/i386/squid-3.0.STABLE10-1.i386.rpm



2) Configuration
I will use the default squid.conf to edit.

vi /etc/squid/squid.conf

หรือ


wget -q -O- "http://devel.pramberger.at/getrepo?release=5" >> /etc/yum.repos.d/pramberger.repo

yum install squid3

วันพุธที่ 25 กันยายน พ.ศ. 2556

วันจันทร์ที่ 23 กันยายน พ.ศ. 2556

การ mount flash drive บน centos

สำหรับท่านที่ต้องการ mount flash drive ที่ฟอร์แมตแบบ ntfs ให้สามารถใช้งานกับ linux centos ได้ให้ทำดังนี้ครับ

1. สำหรับ centos 5.x
ทำการ Enable EPEL ก่อน
## RHEL/CentOS 5 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm

## RHEL/CentOS 5 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm

หลังจากนั้นทำการติดตั้ง ntfs-3g ได้เลย..ผ่าน epel
# yum --enablerepo=epel install ntfs-3g

2. สำหรับ centos 6.x
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

หลังจากนั้นทำการติดตั้ง ntfs-3g ได้เลย..ผ่าน epel
# yum --enablerepo=epel install ntfs-3g

หลังจากที่ติดตั้ง ntfs-3g แล้วก็สามารถ mount flash drive ที่เป็น ntfs บน centos ได้เลยครับ
โดยการตรวจสอบ อุปกรณ์ flash drive ก่อนว่าชื่ออะไรด้วยคำสั่ง

#fdisk -l

หลังจากนั้น ก็สร้างห้องสำหรับ mount อุปกรณ์ผมสร้างไว้ที่ #mkdir /mnt/usb

#mount -t ntfs /dev/sdb1 /mnt/usb เรียบร้อย โดยค่า sdb1 จะเป็นอุปกรณ์ flash drive ที่เสียบไป บางครั้งอาจเป็น sdc1 ขึ้นอยู่กับคำสั่ง fdisk -l ว่าโชว์ชื่ออุปกรณ์ว่าอะไร
#cd /mnt/usb อันเป็นที่เรียบร้อย

วันอังคารที่ 17 กันยายน พ.ศ. 2556

dhcp on centos 6.4

yum -y install dhcp

#nano /etc/sysconfig/dhcpd

DHCPDARGS=eth1 ใส่การ์ดแลนที่ต้องการให้แจก dhcp

#cp /usr/share/doc/dhcp-*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

นำไฟล์คอนฟิกจากตัวอย่างมาแก้ไขเป็นไฟล์ dhcpd.conf ทำการแก้ไขให้เหมาะสม

# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
ddns-update-style none;
authoritative;
log-facility local7;
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.1;
option domain-name-servers 192.168.6.1;
# option domain-name "centos.local";
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.10 10.0.0.100;
}

บันทึกแล้ว start dhcpd
#service dhcpd restart
To Check the DHCP Leases on CentOS Server:

cat /var/lib/dhcpd/dhcpd.leases

วันพฤหัสบดีที่ 5 กันยายน พ.ศ. 2556

การติดตั้ง squid เพื่อแชร์เน็ตใน linux

บทความจากอินเตอร์เน็ตจากเว็บไหน..จำไม่ได้..ขอความโชคดีให้ผู้เขียนบทความ...จงเจริญ

การทำ Transparent Proxy บน Squid
กรณีที่ Squid Server เป็น Gateway

1.ให้ทำการแก้ไขหรือเพิ่มเติมข้อมูลในไฟล์คอนฟิกของ squid (squid.conf) ให้มีบรรทัดต่อไปนี้ :

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

2. ตรวจสอบแพ็กเกตที่วิ่งผ่านเครื่อง Gateway ว่าเป็นการเรียกใช้งาน Port 80 (การเรียกใช้งานเว็บ) หรือไม่ ถ้าเป็นการเรียกใช้งานที่ Port 80 ก็ให้บังคับให้ใช้งานผ่าน squid โดยใช้คำสั่ง ipchains หรือ iptables

กรณี ipchains ให้ใช้คำสั่งดังนี้ :
#ipchians -F
#ipchains -A input -p tcp -s 192.168.1.0/24 -d 0/0 80 -j REDIRECT 8080
หรืออาจจะเป็น
#ipchains -F
#ipchains -A input -p tcp -s 0/0 -d 0/0 80 REJECT 8080

หมายเหตุ ในกรณีที่ squid ทำงานที่ port อื่น เช่น 3128 ก็ให้เปลี่ยน 8080 เป็น 3128


กรณี iptables

ใช้การ์ดแลน 1 การ์ด ให้ใช้คำสั่งดังนี้ :
#echo 1 > /proc/sys/net/ipv4/ip_forward
#iptables -F
#iptables -t nat -F
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

ใช้การ์ดแลน 2 การ์ด โดย eth0 เป็น public และ eth1 เป็น private ให้ใช้คำสั่งดังนี้ :
#echo 1 > /proc/sys/net/ipv4/ip_forward
#iptables -F
#iptables -t nat -F
#iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080

ใช้การ์ดแลน 2 การ์ดและทำ Masquerade ด้วย โดย eth0 เป็น public และ eth1 เป็น private การทำ Masquerade ด้วยจะเป็นผลดี กล่าวคือผมเคยเจอว่าการเรียกเว็บของบางที่ซึ่งมีระบบ Secure ด้วย จะใช้งานไม่ได้ เลยต้องทำ Masquerade ด้วย ซึ่งให้ใช้คำสั่งดังนี้ :
#echo 1 > /proc/sys/net/ipv4/ip_forward
#iptables -F
#iptables -t nat -F
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080

กรณีที่ใช้ Squid ร่วมกับ Cisco Router
ในกรณีที่ Gateway เป็น Cisco Router ก็สามารถทำ Transparent Proxy ร่วมกับ Squid เช่นเดียวกันครับ แต่การทำ ต้องทำทั้งบนเครื่องที่เป็น Squid และบน Cisco Router ซึ่งใช้ Web Cache Communication Protocol (wccp)

ในที่นี้ผมจะยกตัวอย่างแบบง่าย ๆ ที่ผมเคยทดลองใช้งานได้นะครับ (ออกตัวเสียก่อน เพราะจริง ๆ แล้วผมไม่เก่งเรื่อง router มากนัก) วิธีการทำการเป็นดังนี้ครับ

ขั้นที่ 1 ทำที่ Squid
ก็ทำเหมือนกับวิธีการทั่วไปครับ คือ ให้ทำการแก้ไขหรือเพิ่มเติมข้อมูลในไฟล์คอนฟิกของ squid (squid.conf) ให้มีบรรทัดต่อไปนี้ :

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

และในไฟล์ squid.conf จะมีคำว่า :

wccp_router 0.0.0.0

ซึ่งเป็นการกำหนด IP ของ home router โดยค่า default จะเป็น 0.0.0.0 หมายถึงเป็นการ disable wccp ดังนั้นก็ให้เปลี่ยน 0.0.0.0 เป็น IP ของ Router และถ้ามีเครื่องหมาย # นำหน้าก็ให้เอาออก

ขั้นที่ 2 การใช้คำสั่งบน Cisco
ให้ใช้คำสั่งสั้น ๆ 4 คำสั่ง ดังนี้ :
Router(conf)#ip wccp version 1 # ผมลองใช้ Version 2 (ซึ่งเป็นค่า default ของ router รุ่นที่ผมใช้) ปรากฎว่ามองไม่เห็น Proxy (Cache Engine)
Router(conf)#ip wccp web-cache
Router(conf)#int e0/0
Router(conf-if)#ip wccp web-cache redirect out

หมายเหตุ ตรง e0/0 อาจจะเป็น e0 หรือ f0 ได้นะครับ ขึ้นอยู่กับรุ่นของ router

คำสั่งที่เกี่ยวข้อง
sh ip wccp
sh ip wccp web-cache detail
sh ip wccp web-cache view
clear ip wccp
clear ip wccp web-cache

จบครับ

วันอังคารที่ 20 สิงหาคม พ.ศ. 2556

block IP ต่างประเทศใน linux

บทความจากเวบ www.icez.net

block IP ต่างประเทศ ไม่ให้ FTP/SSH เข้ามาได้
บทความสิ้นคิดครับ ก๊อปวางเอาได้เลย




iptables -N FTPFILTER
iptables -A FTPFILTER -j REJECT
for i in `wget -qO - http://www.icez.net/files/thaiiplist`; do
iptables -I FTPFILTER -s $i -j ACCEPT
done
iptables -A INPUT -p tcp --dport 21 -j FTPFILTER


ถ้าจะไม่ให้ ssh ได้ด้วยก็
iptables -A INPUT -p tcp --dport 22 -j FTPFILTER

ขอบคุณมากๆ ครับคุณ icez วันนั้นผมก็ได้ข้อมูลจากคุณ icex นี่ละทำให้กรองได้เยอะเลย
ผมก็ขออนุญาติปรับปรุงต่อจากคุณ icez นิดหน่อย ผิดพลาดประการใด รบกวนช่วยกันแก้ให้ด้วยนะครับ

#************************************************
#สั่งเคลีย Firewall ก่อน
iptables -F
#สั่งเคลีย Firewall ก่อน
iptables -X

##ส่วนนี้ใช้สำหรับlist ip ของ FTP มาจาก iplist ท่าน icez
iptables -N ftp_pass
for i in `wget -qO - http://www.icez.net/files/thaiiplist`; do
iptables -A ftp_pass -s $i -j ACCEPT
done

## ในส่วนนี้ทำไว้สำหรับ Block IP ในกรณีฉุกเฉินเช่นตอนโดนยิง
## วิธี Block ก็ iptables -A block_ip -s xx.xx.xx.xx -j DROP

iptables -N block_ip
iptables -A INPUT -j block_ip

## ในส่วนนี้ทำไว้สำหรับ Block Email ดึงข้อมูลจาก www.spamhaus.org
iptables -N block_email
iptables -A INPUT -p tcp --dport 25 -j block_email
curl -s http://www.spamhaus.org/drop/drop.lasso |grep ^[1-9]|cut -f 1 -d ' ' | xargs -iX -n 1 /sbin/iptables -A block_email -s X -j DROP

#ป้องกัน scan Port หรือเปล่านะ
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP

#ตรวจเช็ค State Full
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT


#เฉพาะ FTP เท่านั้นที่เราจะกรอง ก็สั่งให้กระโดดไป ftp_pass
iptables -A INPUT -p tcp --dport 21 -j ftp_pass
iptables -A INPUT -p tcp --dport 20 -j ACCEPT


#เปิด ให้เข้ามา access เฉพาะ Port ที่ต้องการ
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 2222 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT

#ส่วนนี้ให้ดูจาก proftpd คือว่าเราเปิด port 21 ใช้ในการเชือมต่อ แต่ตอนรับส่งข้อมูลจะใช้ port 35000-35999
iptables -A INPUT -p tcp --dport 35000:35999 -j ACCEPT

# icmp ก็รับด้วยเดี่ยว ping ไม่เจอ
iptables -A INPUT -p icmp -j ACCEPT

#นอกเหนือจาก port ที่เราเปิด ก็ Block ซ่ะ (*** ระวังคำสั่งนี้ให้ดีครับ ถ้าทำบรรทัดนี้แล้วอาจจะ ssh ไม่ได้ ถ้าไม่มั่นใจให้เปิดเฉพาะ IP ตัวเองก่อน)
iptables -A INPUT -j DROP

วันศุกร์ที่ 2 สิงหาคม พ.ศ. 2556

TIPS joomla ขึ้น error There was an error uploading this file to the server.

หาก joomla error ดังกล่าว เนื่องจากไฟล์ที่เราอัพโหลดขึ้นไปใหญ่เกินกว่า 2 mb ที่เราตั้งค่าไว้ที่ php.ini ให้ปรับแก้ไขไฟล์ php.ini upload_max_filesize = 200M เอาตามพอสมควร

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

joomla on freebsd 9.1 กรณีไม่สามารถ install module ได้

กรณีติดตั้ง joomla แล้วไม่สามารถที่จะ install พวก module หรือ components ได้ให้ compile php ให้รองรับ mod_fcgid / mod_ruid ดังคำแนะนำของท่าน 360* แห่งเวบ www.thaihostalk.com อยู่ที่การ complie PHP ถ้าใช้ mod_fcgid / mod_ruid ไม่ต้องเปิด 777 เลย

วันศุกร์ที่ 12 กรกฎาคม พ.ศ. 2556

การทำ vitual host บน freebsd 9.1 หากติดปัญหา permission ใส่ตัวนี้ที่ httpd.conf ด้วย โดยเฉพาะ require all granted ServerAdmin webmaster@phayao2.go.th DocumentRoot /home/plan/public_html ServerName plan.phayao2.go.th ServerAlias plan.phayao2.go.th Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all Require all granted

วันพฤหัสบดีที่ 21 มิถุนายน พ.ศ. 2555

การติดตั้ง coova chilli แทน chillispot บน centos
ให้ถอนโปรแกรม chillispot ออก โดยใช้คำสั่ง rpm -e

#rpm -e chillispot-1.1.0.i386

รีบูตเครื่อง

reboot

ให้ติดตั้ง GCC ก่อนจะติดตั้ง coovachilli

#yum install gcc

จากนั้นให้ไป Download coovachilli มา โดยเท่าที่ทดลองดูจะติดตั้งได้กับ version ที่ต่ำกว่า 1.20 เท่านั้น

# wget http://ap.coova.org/chilli/coova-chilli-1.2.5.tar.gz

แตกไฟล์ออก

# tar -zxvf coova-chilli-1.2.5.tar.gz

แล้วติดต้ังโดยเข้าใน dirrectory ก่อน แล้วใช้คำสั่งดังนี้

# cd coova-chilli-1.2.5

# ./configure --prefix=

#make

#make install

ให้แก้ไขไฟล์ /etc/rc.d/init.d/chilli

ก่อน
"$(which start-stop-daemon)"
หลัง
"$(which start-stop-daemon 2>/dev/null)"

จะมีทั่ง 2 ตำแหน่งด้วยกัน ให้แก้ไขทั้ง 2 จุด

ให้สร้างไฟล์ config

#cp /etc/chilli/defaults /etc/chilli/config

แก้ไขไฟล์ #nano /etc/chilli/config

วิธีการติดตั้งก็เหมือนกับการติดตั้ง ทั่ว ๆ ไปที่มีอยู่ใน forum นี้นะครับหรือจะดูจาก link นี้เป็นตัวอย่างก็ได้ครับ
http://www.linuxthai.org/forum/index...331.0#lastPost
หากใช้ version ใหม่กว่านี้มีวิธีการ configure เหมือนกันครับ

แต่ถ้าหากใช้ร่วมกับหน้า log in ของ ม.บู ก็ต้องแก้ไขไฟล์ default หรือ config หากเปลี่ยนชื่อ
แก้ไขตามนี้นะครับ
จาก
HS_UAMHOMEPAGE=http://\$HS_UAMLISTEN:\$HS_UAMPORT/www/coova.html
เป็น
HS_UAMHOMEPAGE=http://\$HS_UAMLISTEN:\$HS_UAMPORT/prelogin

จาก
HS_UAMFORMAT=http://\$HS_UAMLISTEN:\$HS_UAMIPORT/www/login.chi
เป็น
HS_UAMFORMAT=http://\$HS_UAMLISTEEN/wifi/hotspotlogin.php

หากต้องการแจกไอพี..ตั้งแต่ ip ให้แก้ไข

HS_DYNIP=10.1.0.50/24
HS_STATIP=10.1.0.250/24

ยกเลิก redirect web เพื่อให้ popup แสดงได้...

วันจันทร์ที่ 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 อบรมสนุกดี..แต่อบรมเวลาน้อยไปหน่อย..เสียดายวิทยากรเก่ง ๆ กำลังมัน...จบซะแล้ว..

วันศุกร์ที่ 5 พฤศจิกายน พ.ศ. 2553

mrtg บน freebsd

1. ติดตั้ง snmp ผ่าน ports
#cd /usr/ports/net-mgmt/net-snmp/
#make ; make install clean
#rehash

แก้ไข config ไฟล์ ในที่นี้ผมใช้ editor ee นะครับ ท่านจะใช้ pico ก็ได้
#ee /usr/local/share/snmp/snmpd.conf
พิมพ์ 4 บรรทัดนี้ลงไปครับ ของเดิมหากมี ลบ ให้หมด เอา 4 บรรทัดนี้พอ
rouser public noauth
rocommunity public localhost
syslocation gateway at service room
syscontact webmaster@xxx.com
(2 บรรทัดสุดท้าย แก้ไขตามใจชอบครับ)
แล้ว save ครับ

เรียก snmpd ให้ทำงาน
#snmpd &

ตรวจดูว่ามี process snmpd จริงป่าว....
#ps -ax | grep snmpd

หากอยากให้ snmp ทำงานทุกครั้งก็แก้ไข /etc/rc.conf เพิ่ม สองบรรทัดนี้ลงไป

snmpd_enable="YES"
snmpd_flags="-a -Lsd -p /var/run/snmpd.pid"

2. ติดตั้ง MRTG ผ่าน port
#cd /usr/ports/net-mgmt/mrtg/
#make ; make install clean
#rehash
#cfgmaker public@localhost> /usr/local/etc/mrtg/mrtg.cfg

แก้ไข config
#ee /usr/local/etc/mrtg/mrtg.cfg

WorkDir: /home/webmrtg/public_html
Options[_]:growright,bits

***ผม adduser มา 1 คนชื่อ webmrtg แล้วสร้าง public_html ไว้เพื่อใช้เป็น mrtg เวบครับ

#indexmaker --columns=1 --output=/home/webmrtg/public_html/index.html /usr/local/etc/mrtg/mrtg.cfg

#mrtg /usr/local/etc/mrtg/mrtg.cfg
รันไป 3 ครั้ง ก็จะไม่มี warning ครับ

#ee /etc/crontab
พิมพ์ บรรทัดนี้ ต่อท้ายของเดิม
*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg

เพื่อให้กราฟ update ทุก ๆ 5 นาที


ถ้าอยากให้กราฟแสดง cpu และ ram ก็เพิ่ม
code ด้านล่างลงไปในไฟล์ mrtg.cfg
แทรกต่อจาก code html ที่เค้าแสดงสาถานะครับเข้าไปดูแล้วจะรู้เองครับว่าควรแทรกแถวไหน ครับ
### Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@127.0.0.1
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]:   CPU System
LegendO[cpu]:   CPU User
Title[cpu]: CPU Analysis
PageTop[cpu]:

CPU Analysis



### Memory Free ###
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@127.0.0.1
MaxBytes1[mem]: 1030288
MaxBytes2[mem]: 1052216
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Memory Free
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: (MBytes)
Legend2[mem]: (MBytes)
Title[mem]: Memory Analysis
PageTop[mem]:

Memory Analysis

วันจันทร์ที่ 1 พฤศจิกายน พ.ศ. 2553

cpu 64 bit กับการทำ authen บน freebsd

บทความจากเวบ thaibsd.comโดยครูมานิส

ทำเหมือนเดิมครับ แต่เปลี่ยนมาใช้ FreeBSD8.0-amd64 แทน FreeBSD8.0-i386

ยกเลิกการใช้งาน natd แล้วใช้ PF แทน การปรับค่า Config ประมาณนี้ สรุป คือ ใช้ PF เป็น NAT แต่ Squid ให้ใช้ ipfw เหมือนเดิม

# nano /etc/pf.conf

int_if = "em1"
ext_if = "em0"
chilli_if = "tun0"

tcp_services = "{ 80 , 2000, 9000 , 21 }"
icmp_types = "echoreq"

priv_nets = "{ 10.8.0.0/16, 192.168.2.0/24, 192.168.212.0/24 }"


อธิบาย
int_if ="ชื่อการ์ดแลนวงใน"
ext_if ="ชื่อการ์ดแลนวงนอก"

tcp_services = "{ หมายเลข port ที่ต้องการเปิดใช้งาน }"

priv_nets = "{Class IP ของวงภายในที่อนุญาตให้ใช้งานได้}"


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

ยกเลิก natd แล้วใช้ pf แทนดังนี้

#natd_enable="YES"
#natd_interface="LAN ขา WAN"
#natd_flags="-s -u -m"

pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pflog_flags=""

บันทึกไฟล์

# reboot

ตอนนี้ผมเอา FreeBSD 5-6 เครื่อง ที่มี FreeBSD ต่าง versionกัน เช่น
FreeBSD 5.4 , 6.1 , 6.2 , 6.3 , 8.0 , 8.1 ที่ติดตั้งต่างกรรมต่างวาระเพื่อให้เป็น server ที่ให้บริการต่างๆ ในเครือข่าย Cloning มาวิ่งบน VMware EXSi 4.0 นิ่งมากครับ....
RAM 8 GB บนเครื่อง host ยังเหลืออีกเยอะเลยครับ... แบ่งให้ FreeBSDไป เครื่องละ 256 , 512 , 1024 MB. แล้วแต่ว่า load มากน้อยครับ...

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

วิธีแก้ไข apahe22 error กรณี libtool

บทความจากเวบ www.kroonis.org

มีเทคนิคมาฝากครับ จะไม่พบกับ Error-code1 อีกเลย สำหรับมือใหม่ เปิดแล้ว 997 | แสดงความคิดเห็น : 1
มีเทคนิคมาฝากครับ จะไม่พบกับ Error-code1 อีกเลย สำหรับมือใหม่

1. Setup FreeBSD รุ่นที่ชอบ ล่าสุดก็ FreeBSD8.0

2. ตรวจสอบเวลาเครื่องก่อน ว่าเป็นปัจจุบันไหม

# date

ถ้าไม่ตรง ตั้งใหม่ date ปีค.ศ.เดือนวันชั่วโมงนาทีวินาที เช่น

# date 201005110915

3. Update Ports ก่อน ทำตามนี้

# cd /usr/ports/lang/perl5.8

# make install clean

# rehash

# cd /usr/ports/net/cvsup/

# make install clean

ระบบถามอะไร ก็เลือก ตอบ Ok ไปเรื่อยครับ

# rehash

# /usr/local/bin/cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/ports-supfile

# cd /usr/ports && make fetchindex

หลังจาก Update Ports เสร็จใหม่ ๆ อย่าเพิ่งติดตั้งโปรแกรมเสริมนะ ให้ใช้คำสั่งด้านล่างก่อน

# cd /usr/ports/devel/libtool22/ && make FORCE_PKG_REGISTER=yes install && make clean

# rehash

Start ตาม STEP ได้เลย

1. Compile Kernel

2. Setup FAMP (Mysql5 + Apache22 + PHP5 / extensions)

3. โปรแกรมอื่น ๆ

จะไม่พบกับคำว่า Error-code1 อีกเลยครับ

ถ่ายทอดจากประสบการณ์ตรง จริง ๆ ครับ คัดลอกบรรทัดต่อบรรทัด

ฝากจากคุณพรหมมาศ แซ่ลั่ว

ช่วยให้การ error ลดลงแต่อาจจะยังมีบ้างครับ แนะนำอีกอย่างว่าควรทำการ update ports tree ด้วย โดยใช้คำสั่งต่อไปนี้ในครั้งแรก
# portsnap fetch extract update
และในการ update ครั้งต่อ ๆ ไปใช้คำสั่งนี้ครับ
# portsnap fetch update

วันเสาร์ที่ 9 ตุลาคม พ.ศ. 2553

การติดตั้ง dhcpd บน freebsd

การติดตั้ง DHCP บน FreeBSD 7.0 บทความโดย dekdar แห่ง www.thaibsd.com

1. เริ่มจากค้นหา พอร์ตของ dhcp
freebsd# cd /usr/ports/

2. ค้นหาพอร์ตของ dhcp
freebsd# make search name=dhcpd
Port: isc-dhcp3-server-3.0.5_2
Path: /usr/ports/net/isc-dhcp3-server

3. เข้าไดเรกทรอรี่ dhcp เพื่อทำการติดตั้งโปรแกรม
freebsd# cd /usr/ports/net/isc-dhcp3-server

4. เลือกออพชั่น การติดตั้งโปรแกรม
freebsd# make config
Options for isc-dhcp3-server 3.0.5_2
[X] DHCP_PARANOIA add -user, -group and -chroot options
[ ] DHCP_JAIL add -chroot and -jail options
[ ] DHCP_SOCKETS use sockets instead of /dev/bpf (jail-only)
[ ] DHCP_LDAP add experimental LDAP backend support
[X] DHCP_LDAP_SSL support LDAP connection over SSL/TLS
[X] OPENSSL_BASE use the base system OpenSSL (required by TLS)
[ ] OPENSSL_PORT use OpenSSL from ports (required by TLS)
[ ] DHCP_LQ DHCPLEASEQUERY support used by Cisco uBR's
[ OK ] Cancel

5. ทำการติดตั้งโปรแกรม
freebsd# make
freebsd# make install

6. สร้างไฟล์คอนฟิก dhcpd.conf
freebsd# cp /usr/local/etc/dhcpd.conf.sample /usr/local/etc/dhcpd.conf.sample
หรือ
freebsd# touch /usr/local/etc/dhcpd.conf

7. กำหนดค่าคอนฟิกไฟล์
freebsd# pico /usr/local/etc/dhcpd.conf
ddns-update-style ad-hoc;
option domain-name "yiu.edu";
option domain-name-servers 118.175.87.11, 203.113.24.199;
default-lease-time 6000;
max-lease-time 72000;
subnet 118.175.87.8 netmask 255.255.255.248 {
}
# This is a very basic subnet declaration.
subnet 172.30.2.0 netmask 255.255.255.0
{ range 172.30.2.20 172.30.2.250;
option routers 172.30.2.1;
option broadcast-address 172.30.2.255;
}
host server_controll {
hardware ethernet 00:04:e2:80:f7:f0;
fixed-address 172.30.2.254;
} //เป็นการกำหนดค่า แจกไอพี แบบกำหนด

8. สร้างไฟล์จัดเก็บรายละเอียดไอพี ปกติมีมาให้เรียบร้อยแล้วครับ หากไม่มีก็ให้ทำ
freebsd# touch /var/db/dhcpd.leases
freebsd# chmod 777 /var/db/dhcpd.leases

9. ทดสอบการให้บริการ DHCP
//แจกทางการ์ดทุกใบที่เชื่อมต่อ เราสามารถกำหนดเฉพาะการ์ด Network ที่ต้องการได้
freebsd# /usr/local/sbin/dhcpd &
[1] 22810
freebsd# Internet Systems Consortium DHCP Server V3.0.5
Copyright 2004-2006 Internet Systems Consortium.All rights reserved.
For info, please visithttp://www.isc.org/sw/dhcp/
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 32 leases to leases file.
Listening on BPF/vr0/00:13:d3:11:5c:98/118.175.87.8/29
Sending on BPF/vr0/00:13:d3:11:5c:98/118.175.87.8/29
Listening on BPF/rl0/00:e0:4c:5a:5f:0a/172.30.2/24
Sending on BPF/rl0/00:e0:4c:5a:5f:0a/172.30.2/24
Sending on Socket/fallback/fallback-net
[1] Done /usr/local/sbin/dhcpd

10. ตรวจสอบโปรเซส dhcpd
freebsd# ps ax | grep dhcpd
22811 ?? Is 0:00.00 /usr/local/sbin/dhcpd



11. เพิ่มคำสั่งใน /etc/rc.local
freebsd# echo ‘/usr/local/sbin/dhcpd rl0 &’ >> /etc/rc.local //กรณีที่ต้องการแจกทางการ์ด rl0 เท่านั้น

12. เพิ่มคำสั่งใน /etc/rc.conf
freebsd# echo ‘dhcpd_enable="YES"’ >> /etc/rc.conf

สามารถให้งานบริการ DHCP แล้วละครับ ลง reboot เครื่องสักรอบก็ได้ครับ
freebsd# shutdown –r now

ตัวอย่าง ไฟล์ข้อมูลที่แจกไอพีให้แก่เครื่องลูกข่าย จาก /var/db/dhcpd.leases
freebsd# cat /var/db/dhcpd.leases
lease 172.30.2.247 {
starts 5 2008/07/11 15:52:07;
ends 5 2008/07/11 17:32:07;
binding state active;
next binding state free;
hardware ethernet 00:15:af:8b:83:20;
uid "\001\000\025\257\213\203 ";
client-hostname "codename";
}

ตัวอย่าง การคอนฟิกพาธใน เว็ปมิน
System configuration
DHCP server config file /usr/local/etc/dhcpd.conf
DHCP server executable /usr/local/sbin/dhcpd
Path to DHCP server PID file /var/run/dhcpd.pid
DHCP server lease file /var/db/dhcpd.leases

***แนะนำ เมื่อทำถึงขั้นตอนที่ 5 แล้ว ปกติดสามารถทำผ่าน เว็ปมิน
ได้เลยครับ และง่ายกว่าที่ต้องมาพิมพ์และคอนฟิกเอง มีเครื่องมือ
อำนวยความสะดวกก็ใช้ดีกว่าครับ หากจะพิมพ์เองก็ไม่ว่าอะไร (แต่
มันช้า และโอกาสผิดพลาดมีสูงครับ หุหุหุ++)

Detail Test : Install DHCP3 on FreeBSD 7.0
OS : FreeBSD7.0 After Update Ports
Software : Install Ports Program
Apache apache-2.2.9
MySQL mysql-server-5.1.25
PHP php5-5.2.6
Test by dekdard @ gmail.com

ใช้ FreeBSD 7 เป็น DHCP Server ใช้งานได้ปกติ แต่มีข้อความที่ Server ตลอดเมื่อเครื่องลูกข่ายขอหรือ dhcp หมดเวลา ทั้งที่สร้าง /var/db/dhcpd.leases และ chmod 777 แล้ว แก้ไขไงครับ ขอบคุณครับ

แก้ไข dhcpd.conf บรรทัดนี้ครับ
ddns-update-style แก้ไขเป็น ddns-update-style none;
อย่าลืม restart dhcpd ด้วยนะครับ

วันเสาร์ที่ 18 กันยายน พ.ศ. 2553

update ports tree บน freebsd

บทความ จาก thaibsd.com xdisc
ไหนๆจะอัพเดทล่ะก็เอาให้หมดทีเดียวไปเลยครับใช้เวลาไม่นานหรอก แพคเกจบางตัวก็จำเป็นใช้งานร่วมกัน ถ้าตัวใดตัวหนึ่งเก่าเกินไปเวลาติดตั้งอาจมีปัญหาได้

การทำ cvsup เพื่อปรับปรุง ports(ส่วนที่ใช้ในการติดตั้งโปรแกรมอัตโนมัติผ่านอินเตอร์เน็ต)
cvsup จะใช้เพื่อทำการปรับปรุง ports ต่างๆ ของเราให้ทันสมัย เพราะบาง package จำเป็นต้องปรับปรุงให้เป็นเวอร์ชั่นใหม่

ติดตั้ง cvsup ก่อน
# cd /usr/ports/net/cvsup-without-gui
# make install && make clean
# rehash
หรือ
# pkg_add -r cvsup-without-gui
# rehash

ทำการ synchronize ports index กับ cvsup server
# /usr/local/bin/cvsup -g -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/ports-supfile
รอจนกว่าจะติดตั้งเสร็จ
# cd /usr/ports && make fetchindex

จากนั้นก็จะทำให้เราได้โปรแกรมใน /usr/ports เป็นตัวใหม่ล่าสุดแล้ว
อันนี้ของ ครูมานิส..น่าสนใจ..
.................................
1. Setup FreeBSD รุ่นที่ชอบ ล่าสุดก็ FreeBSD8.0

2. ตรวจสอบเวลาเครื่องก่อน ว่าเป็นปัจจุบันไหม

# date

ถ้าไม่ตรง ตั้งใหม่ date ปีค.ศ.เดือนวันชั่วโมงนาทีวินาที เช่น

# date 201005110915

3. Update Ports ก่อน ทำตามนี้

# cd /usr/ports/lang/perl5.8

# make install clean

# rehash

# cd /usr/ports/net/cvsup/

# make install clean

ระบบถามอะไร ก็เลือก ตอบ Ok ไปเรื่อยครับ

# rehash

# /usr/local/bin/cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/ports-supfile

# cd /usr/ports && make fetchindex

หลังจาก Update Ports เสร็จใหม่ ๆ อย่าเพิ่งติดตั้งโปรแกรมเสริมนะ ให้ใช้คำสั่งด้านล่างก่อน

# cd /usr/ports/devel/libtool22/ && make FORCE_PKG_REGISTER=yes install && make clean

# rehash

Start ตาม STEP ได้เลย

1. Compile Kernel

2. Setup FAMP (Mysql5 + Apache22 + PHP5 / extensions)

3. โปรแกรมอื่น ๆ

จะไม่พบกับคำว่า Error-code1 อีกเลยครับ

ถ่ายทอดจากประสบการณ์ตรง จริง ๆ ครับ คัดลอกบรรทัดต่อบรรทัด

วันจันทร์ที่ 13 กันยายน พ.ศ. 2553

clear squid อัตโนมัติ...

สร้างไฟล์ /usr/local/sbin/clear-squid-cache.sh
#!/bin/sh
#clear squid cache script
/usr/local/etc/rc.d/squid stop
/bin/sleep 10
rm -rf /var/cache/*
/bin/sleep 10
/usr/local/sbin/squid -z
/bin/sleep 10
/usr/local/etc/rc.d/squid start



กำหนดโหมดไฟล์
# chmod 755 /usr/local/sbin/clear-squid-cache.sh



การกำหนดเวลาการทำ log rotate แก้ไขไฟล์ /etc/crontab
0 0 * * * root /usr/local/sbin/squid -k rotate -f /usr/local/etc/squid/squid.conf
0 0 * * 0 root /usr/local/sbin/clear-squid-cache.sh

คำสั่งแรกจะทำการ rotate logfile ของ squid ทุกวัน
คำสั่งที่สองจะทำการเคลียร์ cache ของ squid ทุกสัปดาห์

ขอบคุณ คุณพรหมมาศ

วันพุธที่ 14 กรกฎาคม พ.ศ. 2553

tip ป้องกัน Ultrasurf

ป้องกัน Ultrasurf tips จาก yim แห่งthaibsd
สำหรับ freebsd ใช้ route add -net 65.49.2.0/24 10.00.2
สำหรับ linux ใช้ route add -net 65.49.2.0/24 gw 127.0.0.1

ของท่าน chet แห่ง linuxthai
ไฟล์วอลผมครับ

#!/bin/sh
#
# Firewall script for ChilliSpot
# A Wireless LAN Access Point Controller
#
# Uses $EXTIF (eth0) as the external interface (Internet or intranet) and
# $INTIF (eth1) as the internal interface (access points).
#
#
# SUMMARY
# * All connections originating from chilli are allowed.
# * Only ssh is allowed in on external interface.
# * Nothing is allowed in on internal interface.
# * Forwarding is allowed to and from the external interface, but disallowed
# to and from the internal interface.
# * NAT is enabled on the external interface.

IPTABLES="/sbin/iptables"
EXTIF="eth0"
INTIF="eth1"

#Flush all rules
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -F -t mangle

#Set default behaviour
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT

#Block Ultrasurf
iptables -A FORWARD -p tcp --dport 9666 -j DROP
iptables -A FORWARD -p udp --dport 9666 -j DROP

$IPTABLES -A INPUT -s 67.15.183.30 -j DROP
$IPTABLES -A FORWARD -s 67.15.183.30 -j DROP
$IPTABLES -A OUTPUT -s 67.15.183.30 -j DROP

$IPTABLES -A INPUT -p tcp -m tcp --dport 9666 -j DROP
$IPTABLES -A FORWARD -p tcp -m tcp --dport 9666 -j DROP
$IPTABLES -A OUTPUT -p tcp -m tcp --dport 9666 -j DROP

#iptables -A FORWARD -p tcp --dport 443 -j DROP_CUSTOM
#iptables -A FORWARD -p udp --dport 443 -j DROP_CUSTOM


IPALLOW=`cat /root/special.txt | awk '{print $1}'`
iptables -N DROP_CUSTOM
for ipall in $IPALLOW
do
iptables -A DROP_CUSTOM -s $ipall -j ACCEPT
iptables -A DROP_CUSTOM -d $ipall -j ACCEPT
done
iptables -A DROP_CUSTOM -j DROP

# เจอคำพวกนี้ผ่านตา อย่าให้เล็ดลอด
iptables -A FORWARD -m string --string "info_hash" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string ".torrent" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string "get_peers" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string "announce_peers" --algo bm --to 65535 -j DROP

#Allow related and established on all interfaces (input)
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -j REJECT

#Allow related and established from $INTIF. Drop everything else.
$IPTABLES -A INPUT -i $INTIF -j DROP

#Allow http and https on other interfaces (input).
#This is only needed if authentication server is on same server as chilli
$IPTABLES -A INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 443 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT

#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT

#Allow ICMP echo on other interfaces (input).
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

#Allow everything on loopback interface.
$IPTABLES -A INPUT -i lo -j ACCEPT

# Drop everything to and from $INTIF (forward)
# This means that access points can only be managed from ChilliSpot
$IPTABLES -A FORWARD -i $INTIF -j DROP
$IPTABLES -A FORWARD -o $INTIF -j DROP

##### chalee edit
#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 10000 --syn -j ACCEPT

#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3128 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3306 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 10000 --syn -j ACCEPT

#Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

##Allow transparent proxy ##
$IPTABLES -A INPUT -p tcp -m tcp --dport 8080 --syn -j ACCEPT
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 8080 --syn -j DROP
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 192.168.0.0/16 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 172.16.0.0/12 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080

# Drop package wrom Virus Input, Output
$IPTABLES -A INPUT -p tcp --dport 135 -j DROP
$IPTABLES -A INPUT -p udp --dport 135 -j DROP
$IPTABLES -A INPUT -p tcp --dport 445 -j DROP
$IPTABLES -A INPUT -p udp --dport 445 -j DROP
$IPTABLES -A INPUT -p tcp --dport 4444 -j DROP
$IPTABLES -A INPUT -p udp --dport 4444 -j DROP
$IPTABLES -A INPUT -p tcp --dport 5554 -j DROP
$IPTABLES -A INPUT -p udp --dport 5554 -j DROP
$IPTABLES -A INPUT -p tcp --dport 9996 -j DROP
$IPTABLES -A INPUT -p udp --dport 9996 -j DROP
$IPTABLES -A INPUT -p tcp --dport 137 -j DROP
$IPTABLES -A INPUT -p udp --dport 137 -j DROP
$IPTABLES -A INPUT -p tcp --dport 138 -j DROP
$IPTABLES -A INPUT -p udp --dport 138 -j DROP
$IPTABLES -A INPUT -p tcp --dport 139 -j DROP
$IPTABLES -A INPUT -p udp --dport 139 -j DROP

$IPTABLES -A OUTPUT -p tcp --dport 135 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 135 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 445 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 445 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 4444 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 4444 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 5554 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 5554 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 9996 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 9996 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 137 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 137 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 138 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 138 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 139 -j DROP


ส่วนไอพีที่ผมใส่ไปมีแค่นี้ครับ
217.12.8.76
64.4.20.169
97.74.144.165