11/25/2010

Iptables

block IP ต่างประเทศ ไม่ให้ FTP/SSH เข้ามาได้

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

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

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

## ในส่วนนี้ทำไว้สำหรับ Block Email ดึงข้อมูลจาก www.spamhaus.orgiptables -N block_email
iptables -A INPUT -p tcp –dport 25 -j block_emailcurl -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

11/17/2010

Network Tool : Ntop

การติดตั้ง ntop
ตรวจสอบไลบรารีพื้นฐานglibc,gcc,cpp,gawk,libtool,libpcap
ส่วนการแสดงกราฟ ได้แก่ gd ,gd-devel และ libpng ,libpng-devel

# rpm -q glibcglibc-2.5-12
ดาวน์โหลดโปรแกรม ntop ได้จากเว็บไซต์ http://sourceforge.net/projects/ntop/
# cd /tmp/
# tar zxvf ntop-3.2.gz
# cd ntop-3.2.gz
# ./configure
# make
# make install
# ntop
#http://IP:3000

Network Tool : BaCon (Bandwidth Controller)

คุณสมบัติของ BaCon (Bandwidth Controller)
  • สามารถควบคุมปริมาณข้อมูลในแบนด์วิดท์แบบอัตโนมัติ เพื่อให้สามารถใช้ในการรองรับบริการต่างๆในองค์กรได้อย่างมีประสิทธิภาพ
  • ควบคุมปริมาณแบนด์วิดท์เข้าออกเครือข่าย
  • ควบคุมปริมาณแบนด์วิดท์จำแนกตามประเภทของโปรแกรมที่ใช้งานอินเทอร์เน็ต
  • ควบคุมปริมาณแบนด์วิดท์จำแนกตามผู้ใช้
  • กำหนดลำดับความสำคัญ (Priority) ให้กับข้อมูลภายในเครือข่าย
  • กำหนดช่วงเวลาและตั้งเวลาการควบคุมได้
  • พัฒนาระบบการแสดงผลและการจัดเก็บข้อมูลลงในฐานข้อมูล (Database) ที่ผู้ใช้สามารถนำไปใช้ประกอบการตัดสินใจและแก้ข้อบกพร่องของเครือข่ายได้
  • การออกแบบ Interface อย่างง่ายในรูปแบบที่สามารถทำให้ผู้ใช้งานไม่จำเป็นต้องใช้ความรู้ด้านการจัดการบริหารเครือข่ายมากนักก็สามารถเลือกและควบคุมการทำงานในส่วนต่างๆ ของระบบบริหารจัด
  • การแบนด์วิดท์นี้ได้อย่างง่าย โดยผ่าน Web Interface
  • รองรับการใช้งานกับเครือข่าย IPv6

ความต้องการของระบบ
HARDWARE
regular PC computer with at least 2 network interface cards
SOFTWARELinux OS kernel 2.6.21 (fully tested on Fedora Core and LinuxSIS)
Firewall iptable 1.3.8
Netfilter layer7 2.18
web server
PHP
MySQL
ChartDirector
RRDTool

LDAP

LDAP (Lightweight Directory Access Protoco)

LDAP ย่อมาจาก Lightweight Directory Access Protocol คือ โปรโตคอลที่ช่วยให้เราเข้าถึงข้อมูลที่อยู่ใน Directory Service ซึ่งตรงนี้เราจะยังคงจำเพาะเจาะไปที่กลุ่มของ Directory Service ที่มีชื่อรวมกันว่า X.500 ซึ่งภายในกลุ่มของ X.500 ก็จะมีหลายๆ Directory Service เช่น

DAP (Directory Access Protocol)
DSP (Directory System Protocal)
DISP (Directory Information Shadowing Protocol)
DOP (Directory Operational Binding Management Protocol)

โดย LDAP นั้นก็จะวิ่งอยู่บน TCP/IP โปรโคคอลด้วยเช่นกัน ส่วนข้อมูลที่เก็บอยู่ใน Directory นั้นก็จะมีลักษณะเป็น "Entry" ซึ่ง Entry นี้ก็จะเป็นกลุ่มของ Attribute ที่มี Distinguished Name หรือเรียกสั้นๆ ว่า DN เพียงอันเดียว
-Attribute นั้นจะบอกว่า ข้อมูลที่อยู่ใน Directory นั้นมีชนิดของข้อมูล(Type) ว่าสามารถเป็นอะไรได้บ้าง เช่น ตัวอักษร ตัวเลข นอกจากนี้ Attrubute ก็ยังมีหน้าที่บอกได้ว่า ข้อมูลที่จะเอามาใส่นี้สามารถมีค่าได้กี่อัน กี่ค่า
-DN คือ ชื่อของ Entry ที่เค้ามาช่วยเราแยกแยะข้อมูลใน Directory

ที่มา : http://en.wikipedia.org/wiki/X.500

11/16/2010

ตัวอย่าง ประเภทของ server

Web Server(Apache)
FTP Server(ProFTPd/VSFTPd)
Mail Server(Sendmail/Postfix/Dovecot)
Database Server(MySQL/PostgreSQL)
File and Printer Server(Samba)
Proxy Server(Squid)
DNS Server(BIND)
DHCP Server(DHCPd)
Antivirus Server(ClamAV)
Streaming Server
RADIUS Server(FreeRADIUS)
Control Panel(ISPConfig)

11/09/2010

Linux - mount NTFS

Check NTFS package installed
# modprobe ntfs
# grep ntfs /proc/filesystems
ntfs

Mount NTFS
# mount -t ntfs /dev/device /mnt/mountpoint