วันจันทร์ที่ 17 กันยายน พ.ศ. 2555

วิธีการ Block Ultrasurf ให้อยู่หมัดด



Ultrasurf เป็นโปรแกรมทะลุทะลวงบล็อค ครับ 
ไม่ว่าเราจะเขียน script acl บล็อคเว็บไม่เหมาะสม  พวกxxx ต่างๆบน Squid
โปรแกรมนี้ทะลวงบล็อคได้หมดครับ 
สมมติว่า ผมเขียน script บล็อคเว็บ xxx ไว้ ไม่ให้นักเรียนเข้า
แต่ เมื่อเด็กนักเรียนใช้โปรแกรมนี้ เว็บต่างๆที่เราบล็อคไว้ หลุดหมดครับ
ในตัวโปรแกรมนี้ วิ่งผ่านพอร์ต 443 9666 โดยมี www.ultrareach.com เป็นเว็บ proxy ครับ

โค๊ด: [Select]
แก้ Ultrasurf ได้แล้วนะครับ

เครดิตเว็บ http://wow1973.blogspot.com/

วิธีทำ
1. ผมสร้างไฟล์ชื่อ secial.txt  ไว้ที่ /etc/squid/special.txt
โดยที่ ไฟล์ special.txt คือ ชื่อเว็บที่ผม อนุญาตให้เข้าได้ครับ
ในตัวไฟล์ ผมจะพิมพ์ชื่อเว็บ หรือชื่อไอพีของเว็บที่อนุญาต เช่น
hotmail.com
yahoo.com
gmail.com
login.yahoo.com
login.live.com
mail.live.com
65.54.165.136
65.54.165.137
65.54.165.139
65.54.165.169
หรืออะไรก็ว่าไป

2. นำคำสั่งเหล่านี้ ไปแทรกไว้ในตัวไฟล์ชื่อ firewall.iptables ที่ etc/firewall.iptables
หรือใช้คำสั่ง vi /etc/firewall.iptables

IPALLOW=`cat /etc/squid/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 -p tcp --dport 443 -j DROP_CUSTOM
iptables -A FORWARD -p udp --dport 443 -j DROP_CUSTOM

เสร็จแล้ว ทำการ save แล้ว restart เครื่อง แล้ว รอดูผลงาน

Ref : http://www.linuxthai.org/forum/index.php?topic=13401.0

โค๊ด: [Select]
#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

IPALLOW=`cat /etc/squid/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 -p tcp --dport 443 -j DROP_CUSTOM
iptables -A FORWARD -p udp --dport 443 -j DROP_CUSTOM


ใส่เข้าไปด้วยครับ

อีก Trip

ป้องกัน 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
ไฟล์วอลผมครับ

โค๊ด: [Select]
#!/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 

Ref : http://wow1973.blogspot.com/




credit : http://www.giffyhackman.com/webboard/index.php?topic=671.0

วันจันทร์ที่ 3 กันยายน พ.ศ. 2555

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

Acronis True Image Home 2012

Comes with Installer
Serial: AKH7K4E3-XXN4H5BQ-CYP64NAA-WF98JT7T-CLFS3BBM-LKUMEJU4-N78YSFZ8-VZZEYMXW

Registry file to block checking for updates: 
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREAcronisTrueImageHomeSettings]
"AutocheckUpdates"=dword:00000000

Not sure if it still works beyond that however.
Also have user's help guide.

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

การติดตั้ง bind 9 บน ClearOS 5.2

การติดตั้ง bind 9 บน ClearOS 5.2



สำหรับท่านที่ตั้งค่า squid,frox เรียบร้อยแล้ว อาจจะงงๆ ว่าบางครั้ง patch เก็บบ้างไม่เก็บบ้าง ยกตัวอย่าง
เกมส์ audition อัพแพทช์ผ่าน frox  ชื่อโฮส auto3.asiasoft.co.th  ซึ่งจะมี IP หลาย IP เช่น
122.155.11.6
122.155.11.5
203.144.132.3
203.144.132.4
203.144.132.118
203.144.132.119
203.144.132.120

เวลาอัพมันจะวนไปเรื่อยๆ ไม่ซ้ำกัน ทำให้ squid,frox มองว่าเป็นคนล่ะ ip เลยทำการโหลด patch ใหม่อีก แทนที่จะเรียกของเดิมซ้ำ
ซึ่งต้องแก้ไขด้วยการติดตั้ง bind9 ซึ่งในขณะนี้คือรุ่น 9.3.6
yum install bind-chroot
หรือติดตั้ง package ดังนี้
bind-9.3.6-4.P1.el5_5.3.i386.rpm                
bind-utils-9.3.6-4.P1.el5_5.3.i386.rpm         
bind-chroot-9.3.6-4.P1.el5_5.3.i386.rpm         
bind-libs-9.3.6-4.P1.el5_5.3.i386.rpm

จากนั้น เข้า putty ไป
กำหนด premission ของ folder ดังนี้
chmod 755 /var/named/
chmod 775 /var/named/chroot/
chmod 775 /var/named/chroot/var/
chmod 775 /var/named/chroot/var/named/
chmod 775 /var/named/chroot/var/run/
chmod 777 /var/named/chroot/var/run/named/
cd /var/named/chroot/var/named/
ln -s ../../ chroot
cp /usr/share/doc/bind-9.3.6/sample/var/named/named.local /var/named/chroot/var/named/named.local
cp /usr/share/doc/bind-9.3.6/sample/var/named/named.root /var/named/chroot/var/named/named.root
หากมี bind รุ่นใหม่มาอาจต้องแก้ไปตามรุ่นที่ติดตั้ง /usr/share/doc/bind-9.x.x
จากนั้นสร้าง ไฟล์ด้วย
touch /var/named/chroot/etc/named.conf
ตั้งค่า service bind ทุกครั้งหลัง restart server
chkconfig --levels 235 named on
สั้งให้ service bind ทำงาน
/etc/init.d/named start
หรือจะใช้
service named start

จากนั้นเป็นการแก้ไขค่า config  โดย
cd /var/named/chroot/etc
rndc-confgen > rndc.key
ขั้นตอนนี้อาจมี error บ้างไม่ต้องสนใจ
chown root:named rndc.key
 จากนั้น
nano rndc.key
key "rndckey" {
        algorithm       hmac-md5;
        secret          "7gfPMW2w6DPngANRu2qQww4Cg59utJ2k";
};
จากนั้น แก้ไข file rndc.key ให้เหลือคล้ายๆแบบนี้ บรรทัดอื่นลบไปให้หมด

หมดขั้นตอนนี้ bind9 ก็ใช้งานได้

จากนั้นเรามา เริ่มด้วยการสร้างไฟล์  named.conf
touch /var/named/chroot/etc/named.conf
การแก้ไขไฟล์ name.conf ที่ /var/named/chroot/etc/named.conf
nano /var/named/chroot/etc/named.conf
+++++++++++++++++++++++
// we include the rndckey (copy-paste from rndc.key created earlier)
    include "/var/named/chroot/etc/rndc.key";
// assume our server has the IP 192.168.0.1 serving the 192.168.0.0/24 subnet
    controls {
    inet 127.0.0.1 allow { 127.0.0.1; } keys { "rndckey"; };
    inet 192.168.xx.x allow { 192.168.xx.0/24; } keys { "rndckey"; };
    };
    options {
    directory "/var/named";
    pid-file "/var/run/named/named.pid";
    recursion yes;
    allow-recursion {
    127.0.0.1;
    192.168.xx.0/24;
    };
// these are the opendns servers (optional)
    forwarders {
    8.8.8.8;
    202.69.137.137;
    202.69.137.138;
    203.121.130.39;
    };
    listen-on {
    127.0.0.1;
    192.168.xx.x;
    };
    /*
    * If there is a firewall between you and nameservers you want
    * to talk to, you might need to uncomment the query-source
    * directive below. Previous versions of BIND always asked
    * questions using port 53, but BIND 8.1 uses an unprivileged
    * port by default.
    */
    #query-source address * port 53;
 // so people can't try to guess what version you're running
    version "REFUSED";
    allow-query {
    127.0.0.1;
    192.168.xx.0/24;
    };
    };
    server 192.168.xx.x {
    keys { rndckey; };
    };
++++++++++++++++
เช่น clearos server ip 192.168.2.1 ก็แทน 192.168.xx.x  และในกลุ่ม 192.168.xx.0 ด้วย 192.168.2.0
แล้วแก้ไข nameserver ที่ /etc/resolv.conf
nano /etc/resolv.conf
เพิ่ม
nameserver 192.168.xx.x
nameserver 127.0.0.1

สำหรับ audition เพิ่มสคริปตามนี้ ที่บรรทัดสุดท้่าย ของ named.conf
// AUDITION PATCH SERVER //
    include "/var/named/chroot/etc/audition.zone";



จากนั้นก็ สร้างไฟล์ audition.zone ที่ /var/named/chroot/etc/
nano /var/named/chroot/etc/audition.zone

แล้วใส่สคริปตามนี้
zone "auto1.asiasoft.co.th" {
   type master;
   file "/var/named/chroot/etc/audition1.zone";
};
zone "auto2.asiasoft.co.th" {
   type master;
   file "/var/named/chroot/etc/audition2.zone";
};
zone "auto3.asiasoft.co.th" {
   type master;
   file "/var/named/chroot/etc/audition3.zone";
};
zone "auto4.asiasoft.co.th" {
   type master;
   file "/var/named/chroot/etc/audition4.zone";
};

สร้างไฟล์ audition1.zone (จะต้องสร้าง 4 ไฟล์ audition1-4) ที่ /var/named/chroot/etc/
nano /var/named/chroot/etc/audition1.zone
ใส่สคริปตามนี้
*ไฟล์นี้คือ การกำหนดไอพี (fix host) ที่ต้องการ เช่น ไฟล์ audition1.zone ตั้งค่า auto1.asiasoft.co.th เป็นไอพี 122.155.11.8
และไฟล์ audition2.zone ตั้งค่า auto2.asiasoft.co.th ไอพี 122.155.11.7 เป็นต้น

$TTL 24h
@ IN SOA localhost. root.localhost. (
2003052800 86400 300 604800 3600 )
@ IN NS localhost.
@ IN A 122.155.11.8
* IN A 122.155.11.8

ของ auto2.asiasoft.co.th จะป็น
$TTL 24h
@ IN SOA localhost. root.localhost. (
2003052800 86400 300 604800 3600 )
@ IN NS localhost.
@ IN A 122.155.11.4
* IN A 122.155.11.4

ของ auto3.asiasoft.co.th จะป็น
$TTL 24h
@ IN SOA localhost. root.localhost. (
2003052800 86400 300 604800 3600 )
@ IN NS localhost.
@ IN A 122.155.11.6
* IN A 122.155.11.6

ของ auto4.asiasoft.co.th จะป็น
$TTL 24h
@ IN SOA localhost. root.localhost. (
2003052800 86400 300 604800 3600 )
@ IN NS localhost.
@ IN A 122.155.11.5
* IN A 122.155.11.5

สร้างไปจนครบ 4 ไฟล์

# service named restart
***ตัวอย่างการตั้งค่าเกมส์ xshot โหลดแพทช์ผ่าน squid***
สคริปไฟล์ /var/named/chroot/etc/name.conf
// XSHOT PATCH SERVER //
    include "/var/named/chroot/etc/xshot.zone";
สคริปไฟล์ /var/named/chroot/etc/xshot.zone
zone "patchxshot.winner.co.th" {
   type master;
   file "/var/named/chroot/etc/xshot2.zone";
};
สคริปไฟล์ /var/named/chroot/etc/xshot2.zone
$TTL 24h

@ IN SOA localhost. root.localhost. (
2003052800 86400 300 604800 3600 )
@ IN NS localhost.
@ IN A 202.43.35.174
* IN A 202.43.35.174
แก้ไขไฟล์ squid.conf
refresh_pattern ^http://*.winner.* 14400 90% 43200 ignore-reload override-lastmod reload-into-ims override-expire ignore-no-cache ignore-private
แล้วสั่ง
#service squid reload
ท่านใดงง ลองโหลดไฟล์แนบไปศึกษาดูนะครับ 



วิธีติดตั้ง Bind9 บน ClearOS


วิธีติดตั้ง Bind9 บน ClearOS

yum install bind-chroot
chmod 755 /var/named/
chmod 775 /var/named/chroot/
chmod 775 /var/named/chroot/var/
chmod 775 /var/named/chroot/var/named/
chmod 775 /var/named/chroot/var/run/
chmod 777 /var/named/chroot/var/run/named/

cd /var/named/chroot/var/named/
ln -s ../../ chroot
cp /usr/share/doc/bind-9.3.6/sample/var/named/named.local /var/named/chroot/var/named/named.local
cp /usr/share/doc/bind-9.3.6/sample/var/named/named.root /var/named/chroot/var/named/named.root

touch /var/named/chroot/etc/named.conf

chkconfig --levels 235 named on

service named start

cd /var/named/chroot/etc
rndc-confgen > rndc.key
chown root:named rndc.key

vi /var/named/chroot/etc/named.conf  (แก้ไข หรือ Copy ให้ได้ตามตัวอย่างครับ และเปลี่ยน IP 192.168.1.0 ให้ ตรงกับ SERVER เราด้วย)

###############################################################
// we include the rndckey (copy-paste from rndc.key created earlier)
include "/var/named/chroot/etc/rndc.key";

// assume our server has the IP 192.168.1.254 serving the 192.168.1.0/24 subnet
controls {
inet 192.168.1.254 allow { 192.168.1.0/24; } keys { "rndckey"; };
inet 127.0.0.1 allow { 127.0.0.1; } keys { "rndckey"; };
};

options {
directory "/var/named";
pid-file "/var/run/named/named.pid";

recursion yes;

allow-recursion {
192.168.1.0/24;
127.0.0.1;
};

// these are the opendns servers (optional)
forwarders {
8.8.8.8;
208.67.222.222;
202.69.137.137;
202.69.137.138;
203.121.130.39;
};

listen-on {
192.168.1.254;
127.0.0.1;
};

/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
#query-source address * port 53;

// so people can't try to guess what version you're running
version "REFUSED";

allow-query {

192.168.1.0/24;
127.0.0.1;
};
};

server 192.168.1.254 {
keys { rndckey; };
};
###########################################################

service named start

เครติดคุณ Ton-Or

วันอังคารที่ 15 พฤษภาคม พ.ศ. 2555

เทคนิคการดู พื้นที่ในแต่ละ Folder ของ Linux


เทคนิคการดู พื้นที่ในแต่ละ Folder ของ Linux

IN: LINUX
17Jun2010
วันนี้ Server ที่ทำงานอยู่มีปัญหา Hard disk เต็ม เลยได้โอกาสลองหาวิธีการจัดการดู ถ้าปัญหานี้เกิดบน Mac คงใช้โปรแกรม OmniDisksWeeper ในการตรวจสอบ แต่บน Linux ไม่รู้ใช้ตัวไหนดี เลยลองคำสั่ง classic ดู
$ du / -h | grep "[0-9]G"
du -h คือให้แสดงขนาดของ Folder ออกมาทั้งหมด โดยแสดงขนาดเป็นหน่วยที่คน (h=human) อ่านออก
grep "[0-9]G" คือให้หยิบมาเฉพาะบรรทัดที่มี ตัวเลขตามด้วยอักษร G
ผลที่ได้จะออกมาประมาณนี้
7.6G /home/xxx/.VirtualBox/HardDisks
7.7G /home/xxx/.VirtualBox
18G /home/xxx
20G /home
พอลอง search เพิ่มเติม ก็พบว่ามันสามารถ sort ได้ด้วย
$du -h | grep "[0-9]G" | sort -n -r > du.txt
$du -h | grep "[0-9]G" | sort -n -r | less
ใครอยากดูแบบละเอียดก็เปลี่ยน G เป็น M แทนนะครับ
ที่มา : apirak.com

วันอาทิตย์ที่ 6 พฤษภาคม พ.ศ. 2555

block virus

#!/bin/sh #--- check ip wan ---# ppp0=`ifconfig | grep -A1 ppp0 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "` ppp1=`ifconfig | grep -A1 ppp1 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "` ppp2=`ifconfig | grep -A1 ppp2 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "` #--- check gw wan ---# ppp0_gw=`ip route | grep ppp0 | head -1 | cut -f 1 -d " "` ppp1_gw=`ip route | grep ppp1 | head -1 | cut -f 1 -d " "` ppp2_gw=`ip route | grep ppp2 | head -1 | cut -f 1 -d " "` #--- add new SNAT ---# iptables -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source $ppp0 iptables -t nat -A POSTROUTING -o ppp1 -j SNAT --to-source $ppp1 iptables -t nat -A POSTROUTING -o ppp2 -j SNAT --to-source $ppp2 #iptables -I INPUT -j ACCEPT iptables -I FORWARD -j ACCEPT iptables -I OUTPUT -j ACCEPT iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp -d 10.0.1.1/20 --dport 3128 -j DROP iptables -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.1.1/20 --dport 3128 -j DROP #--- gmember ---# iptables -t nat -I PREROUTING -i eth1 -p tcp -d youtube.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d hi5.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d facebook.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 203.151.207.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d song.gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.4.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.56.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 208.43.218.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d rcw.ms --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d forums.overclockzone.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d overclockzone.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 202.170.126.119/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 216.239.61.100/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 203.144.244.116/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 164.115.2.135/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.56.184/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 203.146.140.137/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 208.43.218.80/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 38.117.107.188/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.242.26/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 69.65.59.240/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 209.17.69.4/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 61.19.12.17/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d youtube.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d hi5.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d facebook.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 203.151.207.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d song.gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 174.36.4.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 174.36.56.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 208.43.218.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d rcw.ms --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d forums.overclockzone.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d overclockzone.com --dport 80 -j ACCEPT #--- HTTP Proxy service ---# if [ -f /var/run/squid.pid ]; then iptables -t nat -D PREROUTING -s 0/0 -i eth1 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -D PREROUTING -s 0/0 -i tun0 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -D PREROUTING -i eth1 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT iptables -t nat -D PREROUTING -i tun0 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT iptables -t nat -A PREROUTING -s 0/0 -i eth1 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -A PREROUTING -s 0/0 -i tun0 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -I PREROUTING -i eth1 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT fi iptables -t mangle -A PREROUTING -i tun0 -m state --state NEW -j MULTIWAN_MARK iptables -t mangle -A PREROUTING -i tun0 -m state --state RELATED,ESTABLISHED -j MULTIWAN_RESTORE iptables -t mangle -A PREROUTING -m state --state NEW -j MULTIWAN_MARK iptables -t mangle -A PREROUTING -m state --state RELATED,ESTABLISHED -j MULTIWAN_RESTORE iptables -t mangle -I PREROUTING -j ACCEPT # Algo string iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j DROP iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP iptables -A FORWARD -m string --algo bm --string "peer_id=" -j DROP iptables -A FORWARD -m string --algo bm --string ".torrent" -j DROP iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP iptables -A FORWARD -m string --algo bm --string "torrent"" -j DROP iptables -A FORWARD -m string --algo bm --string "announce"" -j DROP iptables -A FORWARD -m string --algo bm --string "info_hash" -j DROP #codered virus iptables -A FORWARD -m string --algo bm --string "/default.ida?" -j DROP #nimda virus iptables -A FORWARD -m string --algo bm --string ".exe?/c+dir" -j DROP iptables -A FORWARD -m string --algo bm --string ".exe?/c_tftp" -j DROP # Block Bit 100% iptables -t filter -I FORWARD -i eth+ -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP iptables -t filter -I FORWARD -i tun0 -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP iptables -t filter -I FORWARD -i ppp+ -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP iptables -t filter -I FORWARD -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP # bittorrent key iptables -A FORWARD -m string --string "peer_id" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "BitTorrent" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "BitTorrent protocol" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "bittorrent-announce" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "announce.php?passkey=" --algo kmp --to 65535 -j DROP # ----- Block Bit iptables -A FORWARD -m ipp2p --ipp2p -j DROP iptables -I INPUT -s 0.0.0.0/0 -m string --string "info_hash" --algo bm -j DROP iptables -I INPUT -s 0.0.0.0/0 -m string --string "torrent" --algo bm -j DROP iptables -I INPUT -s 0.0.0.0/0 -m string --string "announce" --algo bm -j DROP # DHT keyword iptables -A FORWARD -m string --string "info_hash" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "get_peers" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "announce" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "announce_peers" --algo kmp --to 65535 -j DROP #--- Block Bit layer7 ---# iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu iptables -I OUTPUT -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu iptables -I FORWARD -m ipp2p --bit -j DROP iptables -I INPUT -m ipp2p --bit -j DROP iptables -I OUTPUT -m ipp2p --bit -j DROP # Drop package wrom Virus Input iptables -I INPUT -p tcp --dport 135 -j DROP iptables -I INPUT -p udp --dport 135 -j DROP iptables -I INPUT -p tcp --dport 4444 -j DROP iptables -I INPUT -p udp --dport 4444 -j DROP iptables -I INPUT -p tcp --dport 5554 -j DROP iptables -I INPUT -p udp --dport 5554 -j DROP iptables -I INPUT -p tcp --dport 9996 -j DROP iptables -I INPUT -p udp --dport 9996 -j DROP iptables -I INPUT -p tcp --dport 137 -j DROP iptables -I INPUT -p udp --dport 137 -j DROP iptables -I INPUT -p tcp --dport 138 -j DROP iptables -I INPUT -p udp --dport 138 -j DROP iptables -I INPUT -p tcp --dport 139 -j DROP iptables -I INPUT -p udp --dport 139 -j DROP # Drop package wrom Virus Output iptables -I OUTPUT -p tcp --dport 135 -j DROP iptables -I OUTPUT -p udp --dport 135 -j DROP iptables -I OUTPUT -p tcp --dport 4444 -j DROP iptables -I OUTPUT -p udp --dport 4444 -j DROP iptables -I OUTPUT -p tcp --dport 5554 -j DROP iptables -I OUTPUT -p udp --dport 5554 -j DROP iptables -I OUTPUT -p tcp --dport 9996 -j DROP iptables -I OUTPUT -p udp --dport 9996 -j DROP iptables -I OUTPUT -p tcp --dport 137 -j DROP iptables -I OUTPUT -p udp --dport 137 -j DROP iptables -I OUTPUT -p tcp --dport 138 -j DROP iptables -I OUTPUT -p udp --dport 138 -j DROP iptables -I OUTPUT -p tcp --dport 139 -j DROP

มาปรับจูน DNS Server

มาปรับจูน DNS Server กันเถอะ(Clear os) Posted on 2011/09/05 DNS เป็นระบบจัดการในการแปลงจากชื่อไปเป็นหมายเลข IP Address (name-to-IP Address mapping) หรือในทางกลับกันมันก็สามารถแปลงจาก IP Address ไปเป็นชื่อที่มีการตั้งไว้ DNS ถือเป็นฐานข้อมูลแบบ กระจายชนิดหนึ่งที่มีการถูกเรียกใช้งานมากที่สุดและมีการเปลี่ยนแปลงมากที่สุดบนโลกใบนี้ ในระบบ DNS จะมี การเก็บชื่อและ IP Address ของเครื่องที่เกี่ยวข้องอย่างเป็นระบบลักษณะการทำงานจะเป็นแบบ Client/Server โดยที่ตัว Server จะเป็นตัวเก็บข้อมูลต่าง ๆ ที่เรียกว่าเป็น DNS Server (ที่มา : http://www.asiamediasoft.net/content/newboard/HowDNS) Dnsmasq เป็น DNS Server ชนิด forwarder+Caching แบบง่ายๆ ตัวเล็ก ประสิทธิภาพสูง (ถึงไม่เท่า Bind ก็เถอะ) และยังสามารถแจก DHCP ได้อีกด้วย ทุกอย่างที่ว่านี้มีอยู่ใน Clark Connect อยู่แล้วครับ ถ้าตอนติดตั้งไม่ลืมเลือกหัว DHCP and Caching DNS Servers มาด้วย จะเกิดอะไรขึ้นถ้า DNS Server หลักล้ม หรือไม่อัพเดทฐานข้อมูล หรืออัพเดทช้า หรือบางเว็บไซต์ที่นิยมๆถูกบล็อกจาก DNS บาง Server ลองนึกสภาพที่ไม่มี DNS Server อยู่ในร้านดูสิครับ จะเกิดอะไรขึ้น!!! เริ่มแรกกันเลย Copy สคิปที่อยู่ด้านล่างไปแทนที่อันเก่าที่ /etc/dnsmasq.conf # The “interface” parameter is set by the network policy (LAN/DMZ interfaces) bogus-priv # maybe make larger cache-size=512 # dhcp-authoritative dhcp-lease-max=1000 # block silly requests domain-needed filterwin2k # domain=system.lan expand-hosts # no-negcache strict-order user=nobody # Can make specific servers here and not use resolv.conf server=203.146.237.237 # csloxinfo 39 server=203.121.130.40 # Pacific 39.9 server=203.144.255.72 # asianet 40.9 server=202.69.137.137 # Triple T Global Net 41 server=202.44.144.33 # KSC 41.5 server=203.146.102.231 # truefaster 42.5 server=203.144.255.71 # asianet 42.8 server=202.129.27.134 # cattelecom 43.6 server=202.69.137.138 # Triple T Global Net 45 server=203.146.237.222 # csloxinfo 48.5 server=202.57.160.129 # Issp 48.9 server=202.6.100.1 # ABAC 50 server=203.121.130.39 # Pacific 51.5 server=203.155.33.1 # KSC 51.9 server=202.44.68.3 # Sripatum 52.7 server=203.144.207.49 # asianet (True) 54.5 server=203.144.207.29 # asianet (True) 58.1 server=202.57.128.71 # SGA 62 server=203.147.0.3 # Jasmine Internet 62.4 server=61.19.245.246 # cattelecom * server=61.19.254.134 # cattelecom * server=202.47.249.4 # cattelecom * server=203.148.255.70 # A-Net * server=203.148.255.78 # A-Net * server=203.149.0.2 # Samart * server=203.149.0.3 # Samart * server=203.146.222.3 # buddybb * server=203.158.144.1 # Rmutp * server=203.146.64.33 # Tnet * server=202.182.0.1 # FarEast * server=202.182.0.2 # FarEast * server=192.150.249.11 # Thammasat * server=208.67.222.222 # OpenDNS 277.8 server=208.67.220.220 # OpenDNS 285.1 # include another configuration conf-file=/etc/dnsmasq/dhcp.conf แก้ไข /etc/resolv.conf ตามสคิปด้านล่าง โค๊ด: nameserver 127.0.0.1 nameserver 192.168.1.1 สั่ง service dnsmasq restart ถ้าใครมีอะไีรเพิ่มเติมหรือชี้แนะ ก็เชิญได้เต็มที่เลยครับ เพราะผมก็ศึกษามาแบบงูๆปลาๆเหมือนกัน ส่วน list รายชื่อ dns server ที่ผมใส่มานั้น ผมได้ใช้เวลาหามาเกือบ 1 วันเต็ม จัดเรียงตามเร็ว (ping x+y+z/n) และคัดอันที่ใช้ไม่ได้หรือมีปัญหาิทิ้งแล้ว และทุกรายชื่อใช้ข้ามค่ายกันได้ครับ ใครมีรายชื่อเพิ่มเติมนอกจากนี้ก็โพทบอกได้เลยครับ (ควรเอา DNS ที่ตรง ISP ไปไว้แรกๆ) หรือถ้าใครอยากศึกษาคำสั่งเพิ่มเติม ก็ไปศึกษาได้ที่นี้เลยครับ http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

วันพุธที่ 29 กุมภาพันธ์ พ.ศ. 2555

ข้อดีของการเช่าในระบบ Cloud Computing

เชื่อมต่อสาขาได้ทันที : เหมาะสำหรับธุรกิจที่มีสาขา และต้องการดูข้อมูลรวมทุกสาขา
Server แรง : SML ลงทุนเครื่อง Server ขนาดใหญ่ และหลายเครื่อง เพื่อให้งานของผู้ใช้ ทำงานรวดเร็ว ไม่สดุด แม้มีจำนวนผู้ใช้มาก
ใช้ได้ตลอดเวลา : ใช้งานได้ตลอด 24 ชม. แม้หน้าร้านปิดไปแล้ว ก็สามารถตรวจสอบข้อมูลที่บ้านได้
ลดการลงทุน : ท่านไม่ต้องซื้อ Server หลายหมื่นบาท และไม่ต้องจ้างพนักงานดูแลระบบ
ประหยัดค่าใช้จ่าย : ไม่ต้องเช่า Internet ความเร็วสูง หรือทำ Fixed IP สำหรับ Server ของท่าน เพราะ Cloud สามารถรองรับการใช้งานพร้อมกันได้ปริมาณมาก และที่สาขาสามารถใช้ Net อะไรก็ได้ เพื่อเข้าใช้ระบบ เช่น 3BB Hotsport ก็แค่เดือนละ 100 แค่นี้ก็เชื่อมสาขาได้ทุกที่
ปลอดภัย : เข้ารหัสถึงสองชั้น เพื่อป้องกันข้อมูลรั่วไหล
รวดเร็ว : ท่านสามารถขึ้นระบบได้ทันที และเชื่อมต่อสาขาได้ทันที
มั่นคง : มีระบบการสำรองข้อมูลให้ทุกเวลา โดยท่านสามารถ Backup ข้อมูลไปเก็บไว้ได้เอง

วันอาทิตย์ที่ 26 กุมภาพันธ์ พ.ศ. 2555

Percona XtraDB Cluster

Percona XtraDB Cluster

http://www.percona.com/doc/percona-xtradb-cluster/index.html#

Percona Data Recovery Tool for InnoDB

https://launchpad.net/percona-data-recovery-tool-for-innodb

innotop The best top clone for MySQL, with special attention paid to InnoDB

http://code.google.com/p/innotop/

innotop
The best top clone for MySQL, with special attention paid to InnoDB

[[Multi-Master Replication Manager for MySQL]]

[[Multi-Master Replication Manager for MySQL]]

http://mysql-mmm.org/

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