แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - golfreeze

Pages: 1 ... 70 71 [72] 73
1066
สำหรับ Mainboard ASUS P5GC-MX/1333 ตัว Lan คือ Atheros น่ะครับ

รุ่นนี้จะให้ Lan on board มาเป็น Attansic L2 100Mbit Ethernet Adapter และมี source driver
ให้เว็บไซต์ผู้ผลิตด้วย ซึ่งดีมากๆ

แต่สำหรับชาว Debian,ubuntu ง่ายกว่านั้นครับ เพราะมีใน apt-get เลย

วันนี้ ผมทดสอบ ลง Debian 4.0 R5 i386 ใน kernel มี driver net atl1 อยู่นะครับ แต่ว่าตัวรุ่นที่มากับ
MB เป็น atl2 ลอง modprobe แล้วได้บ้าง ไม่ได้บ้าง ลอง reboot ก็หลุดไปเลย

ลองติดตั้ง driver atl2 จาก apt-get เลยดีกว่าครับ
- อันดับแรก ตรวจสอบ kernel vesion ก่อนครับ ด้วย uname -a
- package driver คือ atl2-module นะครับ เลือกให้ตรงกับ kernel ของเรา ลอง apt-cache search
atl2-module ดูครับ แล้วสั่ง apt-get install atl2-module-xxxx
- ลอง modprobe atl2
- สั่ง ifconfig ethx ดู (ผมไม่รู้ว่าเครื่องอื่นๆจะเป็น eth ไหนนะครับ ถ้ามีอันเดียวก็ eth0 ครับ)

อ้างอิง http://blog.eulinux.org/2008/05/attansic-l2-100mbit-ethernet-adapter-on.html

1067
command , shell script ,tool , crontab / tcpdump and tshark howto na ja
« on: มกราคม 23, 2011, 12:55:32 AM »
วันนี้ ได้ลองใช้ tshark ดูครับ

การทำงานคล้ายๆ tcpdump แต่มีในส่วนของ data และก็ header packet ที่ค่อนข้างละเอียดกว่า tcpdump ครับ

การใช้งานก็คือ เริ่มลงไปก่อน ผมลงกับ debian นะครับ

#apt-get update
#apt-get install tshark

ก็เรียบร้อยครับผม

ต่อมาเริ่ม capture packet ที่มาจาก ip 192.168.33.1 port 25 แล้วก็เก็บไฟล์ ที่ capture ได้ที่ ไฟล์
ไฟล์หนึ่งเพื่อนำไปวิเคราะห์ ผลโดย

#tshark -i eth0 tcp port 25 and host 192.168.33.1 -w /tshark/tshark_19_20100217_03.cap

แต่ถ้าใช้เป็น tcpdump ก็ดูได้จาก command โดยที่จะ filter source ip ที่มาจาก 192.168.33.1 นี้นะครับ
แล้วเก็บไฟล์ไว้ที่ test.cap เพื่อไปวิเคราะห์ต่อไป
#tcpdump src host 192.168.33.1 and port 8080 -w test.cap

หรือต้องการ เก็บเป็นไฟล์ที่สามารถดูเป็นข้อมูลได้เลยก็

#tcpdump src host 192.168.33.1 and port 8080 > test.txt

ในกรณี ต้องออกจาก screen ก่อนนะครับ ไม่งั้นมันจะ print ข้อมูลออกมาเลย

1068
Mail issue , problem , configuration / update clamav in debian and freebsd
« on: มกราคม 23, 2011, 12:55:00 AM »
ทั้งสอง os ผมจะให้มันอัฟเดทผ่าน source กับ port นะครับเพื่อง่ายและเป็น มาตรฐานของ packetlove.com

##Debian

เพิ่มใน sources.list

#clamav
deb http://volatile.debian.org/debian-volatileetch/volatile main contrib non-free
deb-src http://volatile.debian.org/debian-volatileetch/volatile main contrib non-free

แล้วสั่ง
#apt-get install clamav clamav-daemon clamav-freshclam clamav-base

แค่นี้ มันก็จะทำการ อัฟเดทให้ครับ

ส่วน option ที่ถามให้ตอบว่า update configuration ไปด้วยเลยน่ะครับ

แล้วลองใช้ dpkg -l | grep \"clamav\"

ก็จะได้ version ใหม่มาแล้วครับผม

###Freebsd
สั่งอัฟเดท port ก่อนนะครับ
#portsnap fetch
#portsnap extract

#cd /usr/ports/security/clamav
#make deinstall

#make install clean (เลือก option 5 ตัวบนครับ มี ARC,ARJ,LHA,UNZOO,UNRAR)

#/usr/local/etc/rc.d/clamav-clamd restart

1069
สมมติเวลา สั่ง

#apt-get update

แล้วเกิด error อย่างข้างล่างนี้ น่ะครับ

Fetched 58.9kB in 15s (3780B/s)
Reading package lists... Done
W: GPG error: http://volatile.debian.orgetch/volatile Release: The following signatures couldn't
be verified because the public key is not available: NO_PUBKEY DFD993306D849617
W: Duplicate sources.list entry http://volatile.debian.orgetch/volatile/main Packages
(/var/lib/apt/lists/volatile.debian.org_debian-volatile_dists_etch_volatile_main_binary-amd64_Packag
es)
W: Duplicate sources.list entry http://volatile.debian.orgetch/volatile/contrib Packages
(/var/lib/apt/lists/volatile.debian.org_debian-volatile_dists_etch_volatile_contrib_binary-amd64_Pac
kages)
W: Duplicate sources.list entry http://volatile.debian.orgetch/volatile/non-free Packages
(/var/lib/apt/lists/volatile.debian.org_debian-volatile_dists_etch_volatile_non-free_binary-amd64_Pa
ckages)
W: You may want to run apt-get update to correct these problems

เหมือนกับว่า เครื่อง server เราไม่มี key แก้ไขโดย

#gpg --keyserver subkeys.pgp.net --recv-keys DFD993306D849617

#gpg --armor --export DFD993306D849617 | apt-key add -

#apt-get update

ก็หายแล้วครับ

แล้วถ้าจะอัฟเดท package ใหม่ๆ ก็ ex.clamav

#apt-get install clamav clamav-daemon clamav-base clamav-freshclam

เดี๋ยวมันจะวิ่งอัฟเดท version ให้ครับผม

1070
### ถ้าจะใช้ syslog-ng ต้องลบ syslog ออกน่ะครับผมเพราะไม่งั้น os จะสับสนกันเองครับ

install syslog-ng
#apt-get install syslog-ng

ลบ script syslog ออกไม่ให้รัน ตอน reboot server
#update-rc.d -f syslog remove

ต่อไป เริ่ม config syslog-ng.conf
#vi /etc/syslog-ng/syslog-ng.conf

หาว่ามี config mail.log หรือไม่
destination df_mail { file("/var/log/mail.log"); };

#mail.* -/var/log/mail.log
log {
source(s_all);
filter(f_mail);
destination(df_mail);
};

ถ้ามีครบ ก็ ไป config logrotate ได้เลยครับ
#vi /etc/logrotate.d/syslog-ng

/var/log/mail.info {
rotate 90
daily
missingok
notifempty
compress
}

/var/log/mail.log {
rotate 90
daily
missingok
notifempty
compress
# delaycompress
}

/var/log/mail.warn {
rotate 90
daily
missingok
notifempty
compress
}

แค่นี้ ครับ

ข้อแม้ ห้ามมีไฟล์ที่ เขียน config อย่างงี้ซ้ำกันใน path "/etc/logrotate.d/"

น่ะครับไม่งั้น เวลาสั่ง logrotate มันจะขึ้นว่า log file มัน duplicate กัน

เสร็จแล้วการ test สั่งให้ logrotate ทำงาน

#logrotate /etc/logrotate.conf

รอสักพัก แล้วไปดูใน path /var/log ก็จะเห็นมัน lorate log ให้ครับผม

ส่วน log file ตัวอื่นก็ทำในลักษณะเดียวกันน่ะครับ

ส่วนการรัน log rotate จะทำงานใน cron.daily ทุกวันอยู่แล้ว ไม่ต้องไป set crontab เพิ่มน่ะครับผม
ถ้าจะเช๊คก็ดูได้ที่
#more /etc/cron.daily/logrotate




ถ้ามีข้อสงสัยก็โฟสไว้ได้น่ะครับผม
golfreeze[at]packetlove.com

1071
all application on unix knowledges by golfreeze / install heartbeat on freebsd
« on: มกราคม 23, 2011, 12:53:18 AM »
##heartbeat port
cd /usr/ports/sysutils/heartbeat/

make config
make install clean


config on ha.cf
#vi /usr/local/etc/ha.d/ha.cf

logfile /var/log/ha-log
debugfile /var/log/ha-debug
logfacility local0
bcast bce1
baud 9600
serial /dev/cuad0
auto_failback on
node mysql0.test.server
node ldap01.test.server
ping 10.0.0.1
respawn hacluster /usr/local/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
keepalive 2
deadtime 10
warntime 5
initdead 30

-----------------------------------------------------------------
อธิบาย ค่า config

logfile /var/log/ha-log
ให้เปิด logfile ไปที่ไฟล์ /var/log/ha-log
debugfile /var/log/ha-debug
ให้เปิด debugfile ไปที่ไฟล์ /var/log/ha-debug
logfacility local0
ให้กำหนดการโชว์ log เป็น 0
bcast bce1
ให้ broadcast packet สำหรับ heartbeat ไปถึงกันผ่าน bce1
baud 9600
ให้เปิดใช้งาน serial port ผ่าน rate 9600
serial /dev/cuad0
ให้เปิดใช้งาน device serial port ที่ cuad0 ปกติ freebsd ใช้ตัว device นี้
auto_failback on
กำหนดให้ทำการ auto failback กรณีตัว master ที่ตายกลับมาทำงานได้ใหม่
node mysql0.test.server
node mysql1.test.server
ชื่อ เครื่องที่ทำการ รัน heartbeat และใช้งาน heartbeat
ping 10.0.0.1
ให้เช็คปิงไปที่ gateway node ถ้า master ping ไม่ได้จะ swap การทำงานไปที่ slave node
respawn hacluster /usr/local/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
เปิดให้ใช้งาน ipfail ในการเช๊ค heartbeat ด้วย
keepalive 2
deadtime 10
ค่าตัวนี้ ใช้ในการระบุหาก master node ตาย ให้ทำการรอประมาณ 10 วินาที แล้วจะย้าย vip ไปที่ slave
node
warntime 5
เตือนเวลา heartbeat ไม่สามารถคุยกันได้
initdead 30
ระบุว่า อีก host ตายในเวลา 30 วินาที กรณี boot เครื่องมาใหม่ แล้วไม่เจออีก node

-----------------------------------------------------------------
###create authkeys file , input below command on shell prompt
( echo -ne "auth 1\n1 sha1 "; \
  dd if=/dev/urandom bs=512 count=1 | openssl md5 ) \
  > /etc/ha.d/authkeys

chmod 0600 /usr/local/etc/ha.d/authkeys

หรือเข้าไป ทำ md5 ที่ link ข้างล่างนี้ก็ได้ครับ
http://7thspace.com/webmaster_tools/online_md5_encoder.html
-----------------------------------------------------------------

#### create file \"haresources\" to share packet
mysql0.test.server 10.0.0.2

ทำการ config ที่ mysql1 ให้มีค่า config เหมือนกันทั้งสามไฟล์
ha.cf
authkeys
haresources

1072
เคยเจอ case ว่าเครื่องเพื่อน โดน hack จาก script
แล้วทำการเปลี่ยนค่า permission ของไฟล์ ls ครับ
เช๊คจากคำสั่ง
#cd /bin
#lsattr
------------------ ./tar
------------------ ./netcat
------------------ ./bzcat
------------------ ./dd
------------------ ./true
------------------ ./zforce
------------------ ./mt
s---ia------------ ./ls

พบว่าค่า attribute ของ command ls ถูกเปลี่ยน
แก้ไขโดย
#chattr -i ls
#chattr -a ls
#chown root:root ls

ผมทำการ copy ไฟล์ ls จากเครื่องอื่นที่เป็น distro เดียวกันมาลงครับ
#cp ls_backup ls
#chattr -s ls

ปกติไฟล์พวกนี้ ไม่สามารถเปลี่ยน owner ได้ตรงๆ เพราะมันติดสิทธิ์ของไฟล์อยู่ ต้องแก้ไขด้วยวิธีข้างบน

แค่นี้ก็ใช้งานได้แล้ว

แล้วก็ตามหาตัวผู้ร้ายต่อไป อิอิ

1073
1 Preliminary Note

In this example I use a Debian Sarge system, and I will show how to convert the mysql-zrm rpm
package to a .deb file and install that one. The procedure is the same for Ubuntu.


2 Alien Installation

Alien is available in the normal Debian repositories, so we can install it like this:

apt-get install alien


3 Converting .rpm To .deb

Next we download the current mysql-zrm rpm package (1.1-1 at the time of this writing):

cd /tmp
wget http://www.zmanda.com/downloads/community/ZRM-MySQL/1.1/Linux/MySQL-zrm-1.1-1.noarch.rpm

To convert it into a .deb package, we simply run

alien MySQL-zrm-1.1-1.noarch.rpm

Afterwards, run

ls -l

in the /tmp directory, and you'll see that alien has created the file mysql-zrm_1.1-2_all.deb.
You'll also notice that alien has counted up the version number, it's now 1.1-2 instead of
1.1-1. If you want to keep the original version number, you must use the -k switch:

alien -k MySQL-zrm-1.1-1.noarch.rpm

will create the file mysql-zrm_1.1-1_all.deb.

To install the new .deb file, we use dpkg -i:

dpkg -i mysql-zrm_1.1-1_all.deb

Now mysql-zrm is installed and fully functional (you still might have to edit its configuration file
though).

If you want to save the dpkg -i step, you can have alien install the package. The command

alien -i MySQL-zrm-1.1-1.noarch.rpm

would convert the original rpm package and immediately install it.

You see, converting .rpm files to .deb files is very easy. You can have a look at

man alien

to learn about what else you can do with alien.

1074
About the script: The script below is used to make an effective and strong firewall for the Gateway
machines. The script is commented to make it self explanatory. This script is completely done using
Iptables.

#!/bin/bash
# iptables, by SysAdmin,
# description: Script for setting IPTABLES rules for Gateway
# processname: iptables

The below options will make us adjust the script parameters in one shot. If there requires a
situation like if we want to swap the eth0 and eth1 for some reason, we can adjust that in the below
option rather than adjusting that for the whole script manually. I am using my network configuration
in here. So modify this according to your requirements.

INTERNALIF="eth1" # Internal Ethernet card identifier
INTERNALNET="192.168.1.0/24" # Internet network address range
INTERNALBCAST="192.168.1.255" # Internal Broadcast address
EXTERNALIF="eth0" # External Ethernet card identifier

# Pathnames
DMESG="/bin/dmesg" # Location of Dmesg
IPTABLES="/sbin/iptables" # Location of Iptables

The section below is used to control the script using “Start” or
“Stop” or “Restart” functions just like controlling services
of a Linux machine. The script has to be called like in example below

# sh /firewall.sh start

if [ "$1" = "" ] # this will make the script to exit if no argument
is present
then
echo "Usage: sh /fire.sh (start|stop|restart)"
exit
else
case "$1" in
stop)
action "Shutting down firewall:" echo
$IPTABLES -F
$IPTABLES -P FORWARD DROP
exit 0
;;
status)
echo "The status command is not supported for iptables"
exit 0
;;
restart|reload)
$0 stop
exec $0 start
;;
start)
echo "Starting Firewall:"
;;
*)
echo "Usage: firewall (start|stop|restart)"
exit 1
esac
fi

To avoid any conflicts that may arise in the implementation of the Firewall, its better to flush
every rules that were actually present in the chains and then to start over.

$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES -F FORWARD

The below are some tweaks that can be done to SysCtl to avoid make kinds of attacks. They are pretty
simple yet effective.

Disabling IP Spoofing attacks:

IP spoofing is one of the most common forms of on-line camouflage. In IP spoofing, an attacker gains
unauthorized access to a computer or a network by making it appear that a malicious message has come
from a trusted machine by “spoofing” the IP address of that machine.

echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter

The below change will stop the Gateway from responding to broadcast pings.

echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Block Source Routing:

Source routing allows the sender of the packet to specify the route that a packet must take in
traveling to the destination. If the selected route is not available for any reason, the packet
would not be delivered. If the recipient replied to the packets, the response would follow the same
route. it can be used to discover the IP addresses of routers within a network. However, it also has
the potential for misuse. A malicious user could use source routing to learn more about a network
that he or she is targeting for attack. Data packets contain information about where they have been
and what machines they have transited. A malicious user might send data into a network in order to
collect information about the network's topology. Its better to block source routing from the
Gateway itself

echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route

Kill timestamps.

echo 0 > /proc/sys/net/ipv4/tcp_timestamps

Trying to prevent SYN flood attacks:

A SYN flood is a form of denial-of-service attack in which an attacker sends a succession of SYN
requests to a target's system. One of most important steps is to enable the operating system's
built-in protection mechanisms like SYN cookies. In Linux, we can set the SYN Cookies in the
following manner.

echo 1 > /proc/sys/net/ipv4/tcp_syncookies

Disable all redirection requests in Gateway machine:

echo 0 >/proc/sys/net/ipv4/conf/all/accept_redirects

The below command enables bad error message protection

echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses

#Allow dynamic ip addresses

echo "1" > /proc/sys/net/ipv4/ip_dynaddr

Its recommend to log packets with impossible addresses. This can be done by giving a positive
parameter to the following sysctl parameter.

echo 1 > /proc/sys/net/ipv4/conf/all/log_martians

Set a local port range:

By default, the local port range is 32768 to 61000 for all new 2.6 kernel based systems. Its
explicitly mentioned in the Firewall script because if we need to increase that further, we can
adjust the port range throug the Firewall script itself.

echo "32768 61000" > /proc/sys/net/ipv4/ip_local_port_range

Denial of Service (DoS) attacks: Denial of Service attack is an attempt by a malicious (or
unwitting) user, process, or system to prevent legitimate users from accessing a resource (usually a
network service) by exploiting a weakness or design limitation in an information system. Examples of
DoS attacks include flooding network connections, filling disk storage, disabling ports, or removing
power. This can be limited by setting timeouts.

echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
echo 1800 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 1 > /proc/sys/net/ipv4/tcp_window_scaling
echo 0 > /proc/sys/net/ipv4/tcp_sack
echo 1280 > /proc/sys/net/ipv4/tcp_max_syn_backlog

Basic Rules of a typical Firewall:

Kill INVALID packets with illegal combination flags.

$IPTABLES -A INPUT -m state --state INVALID -j DROP
$IPTABLES -A FORWARD -m state --state INVALID -j DROP

No restrictions to connections from localhost

$IPTABLES -A INPUT -i lo -j ACCEPT

Reject connections from Outside world to Internal loop back device.

$IPTABLES -A INPUT -d 127.0.0.0/8 -j REJECT

No restrictions for traffic generating from legit internal addresses

$IPTABLES -A INPUT -i $INTERNALIF -s $INTERNALNET -j ACCEPT

Incase we have to use IPv6 addresses in your environment uncomment the below line:

#$IPTABLES -A INPUT -p ipv6 -j ACCEPT

Kill all packets from Outside world claiming to be packets generated from Internal network.

$IPTABLES -A INPUT -i $EXTERNALIF -s $INTERNALNET -j REJECT

Block ICMP requests.

$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -o $INTERNALIF -j REJECT

Prevent Ping flood attacks:

$IPTABLES -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j DROP

Deny pings to local broadcast address:

$IPTABLES -A INPUT -p icmp -d $INTERNALBCAST -j DROP

#Allow all other icmp

$IPTABLES -A INPUT -p icmp -j ACCEPT

No restrictions to established connections:

$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

Dont forward SMB related traffic. Samba Services are one of the most aimed targets by hackers.

$IPTABLES -A FORWARD -o $EXTERNALIF -p tcp --dport 137 -j REJECT
$IPTABLES -A FORWARD -o $EXTERNALIF -p tcp --dport 138 -j REJECT
$IPTABLES -A FORWARD -o $EXTERNALIF -p tcp --dport 139 -j REJECT
$IPTABLES -A FORWARD -o $EXTERNALIF -p udp --dport 137 -j REJECT
$IPTABLES -A FORWARD -o $EXTERNALIF -p udp --dport 138 -j REJECT
$IPTABLES -A FORWARD -o $EXTERNALIF -p udp --dport 139 -j REJECT
$IPTABLES -A INPUT -i $EXTERNALIF -p udp --dport 137 -j REJECT

1. Disable Samba Share

#$IPTABLES -A INPUT -p tcp --dport 137 -j ACCEPT
#$IPTABLES -A INPUT -p udp --dport 137 -j ACCEPT
#$IPTABLES -A INPUT -p tcp --dport 138 -j ACCEPT
#$IPTABLES -A INPUT -p udp --dport 138 -j ACCEPT
#$IPTABLES -A INPUT -p tcp --dport 139 -j ACCEPT
#$IPTABLES -A INPUT -p udp --dport 139 -j ACCEPT

Allow all other connections to be forwarded

$IPTABLES -A FORWARD -o $EXTERNALIF -i $INTERNALIF -j ACCEPT

Allow replies from established connections :

$IPTABLES -A FORWARD -i $EXTERNALIF -m state --state ESTABLISHED,RELATED -j ACCEPT

#Allow yourself to be a DHCP server for your inside network
#Necessary because the default rule allowing valid addresses ignores broadcast

$IPTABLES -A INPUT -i $INTERNALIF -p tcp --sport 68 --dport 67 -j ACCEPT
$IPTABLES -A INPUT -i $INTERNALIF -p udp --sport 68 --dport 67 -j ACCEPT

1. This section is to allow nameserver packets.

cat /etc/resolv.conf | \
awk '/^nameserver/ {print $2}' | \
xargs -n1 $IPTABLES -A INPUT -p udp --sport 53 -j ACCEPT -s

#From here on, we are dealing with connection attempts. These services are not needed for our
Gateway. But just incase we happen to have them up and running, just uncomment and restart the
firewall script.

# ftp-data
#$IPTABLES -A INPUT -p tcp --dport 20 -j ACCEPT

# ftp
#$IPTABLES -A INPUT -p tcp --dport 21 -j ACCEPT
# ssh

#$IPTABLES -A INPUT -p tcp --dport 22 -j ACCEPT
#telnet

#$IPTABLES -A INPUT -p tcp --dport 23 -j ACCEPT

# smtp One per second limt -burst rate of ten
#$IPTABLES -A INPUT -p tcp --dport 25 --syn -m limit --limit 1/s \
# --limit-burst 10 -j ACCEPT
#$IPTABLES -A INPUT -p tcp --dport 25 --syn -j DROP
#$IPTABLES -A INPUT -p tcp --dport 25 -j ACCEPT

# DNS
#$IPTABLES -A INPUT -p tcp --dport 53 -j ACCEPT
#$IPTABLES -A INPUT -p udp --dport 53 -j ACCEPT

# http
$IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT

# POP-3
#$IPTABLES -A INPUT -p tcp --dport 110 -j ACCEPT

# identd
#$IPTABLES -A INPUT -p tcp --dport 113 -j ACCEPT

# https
#$IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT

#VNC Server
#$IPTABLES -A INPUT -p tcp --dport 5801 -j ACCEPT
#$IPTABLES -A INPUT -p tcp --dport 5901 -j ACCEPT
#$IPTABLES -A INPUT -p tcp --dport 6001 -j ACCEPT

##Some ports should be denied and logged.

$IPTABLES -A INPUT -p tcp --dport 1433 -m limit -j LOG --log-prefix "Firewalled packet: MSSQL
"
$IPTABLES -A INPUT -p tcp --dport 1433 -j DROP
$IPTABLES -A INPUT -p tcp --dport 6670 -m limit -j LOG --log-prefix "Firewalled packet:
Deepthrt "
$IPTABLES -A INPUT -p tcp --dport 6670 -j DROP
$IPTABLES -A INPUT -p tcp --dport 6711 -m limit -j LOG --log-prefix "Firewalled packet: Sub7
"
$IPTABLES -A INPUT -p tcp --dport 6711 -j DROP
$IPTABLES -A INPUT -p tcp --dport 6712 -m limit -j LOG --log-prefix "Firewalled packet: Sub7
"
$IPTABLES -A INPUT -p tcp --dport 6712 -j DROP
$IPTABLES -A INPUT -p tcp --dport 6713 -m limit -j LOG --log-prefix "Firewalled packet: Sub7
"
$IPTABLES -A INPUT -p tcp --dport 6713 -j DROP
$IPTABLES -A INPUT -p tcp --dport 12345 -m limit -j LOG --log-prefix "Firewalled packet:
Netbus "
$IPTABLES -A INPUT -p tcp --dport 12345 -j DROP
$IPTABLES -A INPUT -p tcp --dport 12346 -m limit -j LOG --log-prefix "Firewalled packet:
Netbus "
$IPTABLES -A INPUT -p tcp --dport 12346 -j DROP
$IPTABLES -A INPUT -p tcp --dport 20034 -m limit -j LOG --log-prefix "Firewalled packet:
Netbus "
$IPTABLES -A INPUT -p tcp --dport 20034 -j DROP
$IPTABLES -A INPUT -p tcp --dport 31337 -m limit -j LOG --log-prefix "Firewalled packet: BO
"
$IPTABLES -A INPUT -p tcp --dport 31337 -j DROP
$IPTABLES -A INPUT -p tcp --dport 6000 -m limit -j LOG --log-prefix "Firewalled packet: XWin
"
$IPTABLES -A INPUT -p tcp --dport 6000 -j DROP

#Traceroutes depend on finding a rejected port. DROP the ones it uses

$IPTABLES -A INPUT -p udp --dport 33434:33523 -j DROP

#Don't log web or ssl because people surfing for long times lose connection tracking and cause
the system to create a new one, flooding logs.

$IPTABLES -A INPUT -p tcp --dport 80 -j REJECT
$IPTABLES -A INPUT -p tcp --dport 443 -j REJECT

The below rules will be effective it it doesnt match any of the above rules. A log for all
connections will be “noise” and will give us a hard time to find something
relevant from the flooded logs. So the rules below just logs connection requests.

$IPTABLES -A INPUT -p tcp --syn -m limit --limit 5/minute -j LOG --log-prefix "Firewalled
packet:"
$IPTABLES -A FORWARD -p tcp --syn -m limit --limit 5/minute -j LOG --log-prefix "Firewalled
packet:"

#Reject

$IPTABLES -A INPUT -p tcp -j REJECT --reject-with tcp-reset
$IPTABLES -A INPUT -p all -j DROP

$IPTABLES -A FORWARD -p tcp -j REJECT --reject-with tcp-reset
$IPTABLES -A FORWARD -p all -j DROP

#Accept it anyway if it's only output
$IPTABLES -A OUTPUT -j ACCEPT

EXPLICITLY BLOCKING SERVICE PORTS FOR GATEWAY FROM OUTSIDE WORLD

/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 21 # ftp
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 22 # ssh
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 23 # telnet
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 25 # smtp
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 53 # domain
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 79 # finger
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 80 # httpd
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 110 # pop3
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 111 # sunrpc
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 137 # netbios-ns
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 138 # netbios-dgm
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 139 # netbios
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 143 # imap
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 161 # snmp
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 162 # snmp trap
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 443 # https
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 515 # printer
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 1080 # socks
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 2049 # nfs
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 3128 # squid
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 3306 # mysql
/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 5432 # postgres

1. EXPLICITLY BLOCKING SERVICE PORTS FOR UDP CONNECTIONS

/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 21 # ftp
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 23 # telnet
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 25 # smtp
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 53 # domain
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 79 # finger
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 110 # pop3
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 111 # sunrpc
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 137 # netbios-ns
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 138 # netbios-dgm
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 139 # netbios
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 143 # imap
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 161 # snmp
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 162 # snmp trap
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 443 # https
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 515 # printer
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 1080 # socks
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 2049 # nfs
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 3128 # squid
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 3306 # mysql
/sbin/iptables -A INPUT -j DROP -i eth0 -p udp --dport 5432 # postgres

1. this line will prevent people on the internet (or you) from pinging the gateway

/sbin/iptables -A INPUT -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j DROP

exit 0

1075
#ipvs + Heartbeat + Debian4.0 R1 (NAT Mode) ต้องทำ static nat ที่ loadbalance ด้วย

LB1 = install Debian 4.0 R1
LB2 = install Debian 4.0 R1

##Add this in /etc/apt/sources.list
deb http://www.ultramonkey.org/download/3/sargemain
deb-src http://www.ultramonkey.org/download/3sarge main
deb http://ftp.coe.psu.ac.th/debianstablemain
deb-src http://ftp.coe.psu.ac.th/debianstable main

#apt-get update
#apt-get install ultramonkey

ปกติถ้า ทำ HA จะมี config หลักๆ 3 ตัวคือ
#/etc/ha.d/ha.cf , haresources , authkeys
ส่วนของ ipvs จะให้อ่านจากไฟล์ config /etc/ha.cf/ldirectord.cf

#Diagram ก็ประมาณนี้ครับ




####LB1

#vi /etc/ha.d/ldirectord.conf
# Global Directives
checktimeout=10
checkinterval=2
#fallback=127.0.0.1:80
autoreload=no
logfile=\"/var/log/ldirectord.log\" #เก็บไฟล์log ของ ldirector
logfile=\"local0\"
quiescent=yes

# Virtual Server for HTTP
virtual=10.0.1.152:80
real=192.168.0.4:80 masq 2
real=192.168.0.5:80 masq 1
service=http
request=\"test.html\"
receive=\"Test Page\"
scheduler=wrr
#persistent=600
protocol=tcp
checktype=negotiate


#vi haresources

lb1 ldirectord::ldirectord.cf
lb1 LVSSyncDaemonSwap::master
lb1 IPaddr2::10.x.x.152/23/eth0
lb1 IPaddr2::192.z.x.254/24/eth1
-----------------------------------------------------

---------------------------------------
lb1:/etc/ha.d# more authkeys
auth3
#1 crc
3 sha1 ultramonkey


lb1:/etc/ha.d# more ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
bcast eth1 # Linux
mcast eth1 225.0.0.1 694 1 0
auto_failback on
node lb1
node lb2
respawn hacluster /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster


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


####LB2
#vi /etc/ha.d/ldirectord.conf
# Global Directives
checktimeout=10
checkinterval=2
#fallback=127.0.0.1:80
autoreload=no
logfile=\"/var/log/ldirectord.log\"
logfile=\"local0\"
quiescent=yes

# Virtual Server for HTTP
virtual=10.0.1.152:80
real=192.168.0.4:80 masq 2
real=192.168.0.5:80 masq 1
service=http
request=\"test.html\"
receive=\"Test Page\"
scheduler=rr
#persistent=600
protocol=tcp
checktype=negotiate


haresource จะเอาไว้สร้างตัว vip ให้เราน่ะครับ ก็ไม่มีไรมาก 2 ตัวต้องเหมือนกันน่ะครับทั้ง ตัว
master(lb1) กับ slave(lb2)
เพราะว่า
#vi haresources

lb1 ldirectord::ldirectord.cf
lb1 LVSSyncDaemonSwap::master
lb1 IPaddr2::10.x.x.152/23/eth0
lb1 IPaddr2::192.z.x.254/24/eth1

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

Lb2:/etc/ha.d# more authkeys
auth3
#1 crc
3 sha1 ultramonkey


Lb2:/etc/ha.d# more ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
bcast eth1 # Linux
mcast eth1 225.0.0.1 694 1 0
auto_failback on
node lb1
node lb2
respawn hacluster /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster





##Set static nat in loadbalance1 and loadbalance2

#vi /etc/rc.local
iptables -t nat -F
iptables -t nat -A POSTROUTING -j SNAT -o eth1 -s 192.168.0.4 --to 10.x.x.x
iptables -t nat -A POSTROUTING -j SNAT -o eth1 -s 192.168.0.5 --to 10.x.x.x

สั่งให้ อ่าน rc.local ก็
#/etc/rc.local

#เสร็จแล้ว ก็มาทำ ตัวroute สำหรับผมมาติดปัญหาตรงจุดนี้ครับ ซึ่งลองใช้ tcpdump ช่วยก็เห็นว่า packet
มันไม่ส่งจากเครื่อง Rip(192.168.0.4) กับ จุด 5 ไปยังเครื่อง loadbalance
ตรงจุดนี้สำคัญมากน่ะครับคือต้องเรียนรู้เรื่อง network routing table ให้พอเข้าใจก่อน
#netstat -nr
lb1:/home/golf# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
10.0.0.0 0.0.0.0 255.255.254.0 U 0 0 0 eth1
0.0.0.0 10.x.x.x 0.0.0.0 UG 0 0 0 eth1
0.0.0.0 192.168.0.254 0.0.0.0 UG 0 0 0 eth2

***#route add -net 0.0.0.0/0 gw 10.0.0.254 dev eth1
***#route add -net 0.0.0.0/0 gw 192.168.0.254 dev eth2
***#route add -net 192.168.0.0 netmask 255.255.255.0 dev eth2


แล้วก็มา set ให้ เครื่อง loadbalance forward packet มาให้เครื่อง Rip น่ะครับ
#sysctl -a | grep forward
#vi /etc/sysctl.conf
Add
net.ipv4.ip_forward = 1
แล้วสั่งให้ show ค่าออกมาดูน่ะครับ
#sysctl -p

ส่วนเครื่อง web1 / web2
ก็ลงเป็น
#web1 os linux(debian4)
#ip 192.168.0.4
เครื่องฝั่ง internal ก็ไม่มีไรมากครับ ลง app ที่เราจะต้องใช้ แล้วก็จูน ให้เสร็จ ก็เปิดรับ service
ให้ใช้งานได้ก็จบครับ

#set ip
#vi /etc/network/interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.4
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254


#web2 os Freebsd(6.2)
#ip 192.168.0.5

#vi /etc/rc.conf
ifconfig_dc0=\"inet 192.168.0.5 netmask 255.255.255.0\"

ให้มัน restart network 1 ดอก
#/etc/rc.d/netif restart

คราวนี้ลองใช้ telnet เข้า vip ที่เรา set ไว้ดูน่ะครับ
ดังนี้
#telnet x.x.x.x 80
ลอง GET ดูน่ะครับ ถ้าได้ค่าว่า Test Page ก็แสดงว่า work แระ


คำสั่งที่จะใช้งานตรวจสอบว่า มี packet เข้ามาในเครื่องผ่าน nat เปล่าก็
#watch -n 1 "iptables -L -n -t nat -xv"

คำสั่งนี้เอาไว้ track ปัญหาน่ะครับ แล้วให้เขียน output ไปไว้ที่ xx.txt แล้วก็ค่อยไปไล่ๆ ดู
#tcpdump -n -i any port 80 > xx.txt

ดูว่า load balance ทำงานแบบ real time ก็
#watch -n 1 "ipvsadm -L -n --stats"
ได้ครับ

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


---
ในงานที่ต้องรับ connection ที่เยอะๆ นั้นการทำ load balance ก็สามารถช่วยแก้ปัญหาได้ครับ
ทำให้ประสิทธิภาพของงานทำได้ดีมากขึ้น แต่บางครั้งในส่วนของ software ก็อาจจะยังมีบางจุดที่ยังไม่ค่อย
stable พอหรือตาม config ที่อาจจะมีบางจุดที่นักพัฒนายัง implement อยู่
ซึ่งถ้ามองแล้วจะทำงานได้ไม่เท่ากับพวก hardware จริงๆ ซึ่งตัว hareware loadbalance
ค่อยข้างจะมีมาตรฐานพอสมควร ซึ่งพวกองค์กรที่ต้องการ performance แล้วก็แนะนำเป็น hareware (F5)
ดีกว่าครับ แพงดีแต่ก็คุ้มครับ

Lab By
http://www.packetlove.com
golfreeze@packetlove.com
ขอบคุณพี่อัท http://www.siambox.com ที่แนะนำเรื่อง route ครับ และคำแนะนำ อิอิ

1076
อิอิ วันก่อนไปแข่งงาน AirRaid Hacking Challenge BKK 2008 มาครับ
มี trick ที่ใช้คือ

Packet ที่ใช้เป็น aircrack-ng
ลง packet พื้นฐานสำหรับ ตัว aircrack-ng ก่อนโดย
#apt-get build-dep aircrack-ng

ต่อจากนั้นก็หา source file ตัวใหม่ของ aircrack-ng มาลงครับ
#tar zxf aircrack-ng-1-beta.tar.gz
#cd aircrack-ng
#make
#make install

เมื่อลง driver ของ interface DLink แล้วก็
เสร็จแล้วก็ ใช้วิธี search หา SSID ได้คือ
#airodump rausb0
------------------------------------------------------

ต่อมาเป็นวิธีการ set WIfi แบบ command line ครับ

ปลอม mac address โดยเปลี่ยนจากตัวเดิมเป็น 00:00:00:00:00:00 โดย
#ifconfig rausb0 hw ether 00:00:00:00:00:00 -arp

ค่า mac นี้เมื่อ restart เครื่องก็จะกลับเป็นค่าเดิมครับ

#ifconfig rausb0 10.x.x.x netmask 255.x.x.x up
#iwconfig rausb0 essid "XXX"
#iwconfig rausb0 key "xxdddffff"

แค่นี้ก็ปิง เครื่อง อื่นๆ ใน nw นั้นได้แล้วครับ

#route add default gw 10.x.x.y

อ่านเพิ่มเติมที่ http://golfreeze.packetlove.com/guyblog/?p=25

golfreeze[at]packetlove.com

1077
You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For
example to find file in last 2 months (60 days) you need to use -mtime +60 option.

* -mtime +60 means you are looking for a file modified 60 days ago.
* -mtime -60 means less than 60 days.
* -mtime 60 If you skip + or - it means exactly 60 days.

So to find text files that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -print

Display content of file on screen that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -exec cat {} \;

Count total number of files using wc command
$ find /home/you -iname "*.txt" -mtime -60 | wc -l

You can also use access time to find out pdf files. Following command will print the list of all pdf
file that were accessed in last 60 days:
$ find /home/you -iname "*.pdf" -atime -60 -type -f

List all mp3s that were accessed exactly 10 days ago:
$ find /home/you -iname "*.mp3" -atime 10 -type -f

There is also an option called -daystart. It measure times from the beginning of today rather than
from 24 hours ago. So, to list the all mp3s in your home directory that were accessed yesterday,
type the command
$ find /home/you -iname "*.mp3" -daystart -type f -mtime 1

1078
RAID ที่นิยมกันก็มี 0 , 1 , 5 , 0+1 , 1+0 เท่านั้นเอง บางคนอาจสงสัยว่า มีด้วยเหรอ RAID 1+0
อ่านต่อกันนะครับ

คำอธิบาย Logic Drive หมายถึง Drive ที่สร้างขึ้นมาจาก RAID นะครับ

RAID 0
RAID 0 เป็นแบบที่ง่ายและเป็นพื้นฐานที่สุดเลย คือ ทำการรวม HDD 2 ตัว (หรือมากกว่า) ให้กลายเป็น HDD
ตัวเดียวกัน (เรียกว่า Logic Drive) เช่น ถ้ามี HDD 40G 2 ตัว ตัวแรกจะเป็น C อีกตัวก็จะเป็น D
เมื่อเราแปลงเป็น RAID 0 เนื้อที่ของทั้ง 2 ตัวก็จะรวมกันเป็น Drive เดียวกัน ชื่อ C มีขนาด 80G
โดยเมื่อแปลงเป็น RAID 0 แล้ว OS และโปรแกรมต่างๆ ก็จะมอง Drive ใหม่นี่ เสมือนเป็น Drive
เดีวยวกันที่สามารถอ่านเขียนข้อมูลต่างๆ ได้ตามปกติ
ข้อดี คือ ทำให้การอ่านหรือเขียนข้อมูลเร็วขึ้นมาก เพราะมีหัวอ่าน/เขียนข้อมูลเพิ่มมากขึ้น (ในระบบ
SCSI
นะครับ ถ้า IDE หัวอ่านเพิ่มขึ้น ก็ไม่เร็วขึ้นหรอก ไปอ่านที่ อันแรกก็ได้ครับ)
และมันยังขยายเนื้อที่สำหรับเก็บข้อมูลได้ง่ายขึ้นด้วย
ข้อเสีย เนื่องจากมันไม่ได้ทำการสำรองข้อมูลเลย หรือแม้แต่ Parity Bit มันก็ไม่ได้ทำ (แม้แต่นิดเดียว)
ถ้า HDD ตัวไหนเสีย มันจะทำให้ Logic Drive ที่เราสร้างขึ้น เสียไปทั้งหมด ข้อมูลของเราก็จะหมดไปด้วย
(เศร้า)

RAID 1
RAID 1 ต่างจาก RAID 0 แบบว่า หน้ามือเป็นหลังมือเลย เนื่องจาก RAID 1 จะเก็บข้อมูลทั้งหมดลง HDD
ตัวแรก
เหมือนการใช้งานทั่วๆ ไป แต่จะมี HDD ตัวที่สองเพิ่มเข้ามา เราเรียก HDD ตัวนี้ว่า MIRRORING หรือ
DUPLEXED โดยที่ HDD ตัวทั่สองนี้ จะทำการสำรองข้อมูลจากตัวแรก เพื่อป้องกันการสูญหายของข้อมูล
โดยมีข้อกำหนดว่า HDD ทั้ง 2 ตัว ต้องขนาดเท่ากันพอดี ถ้าเป็นไปได้ ควรจะเป็นยี่ห้อ
และรุ่นเดียวกันด้วย
ข้อดี อย่างที่เห็นล่ะครับ ข้อมูลจะถูกสำรองไว้ตลอดเวลา ไม่ต้องกลัวว่าจะหายเลย ถ้า HDD ตัวไหนเสีย
อีกตัวก็จะขึ้นมาทำงานแทนทันที ถ้าเป็น Server ที่มีระบบ Hot Swap เราสามารถถอด HDD ตัวที่เสีย
ไปเปลี่ยน แล้วเอาตัวใหม่มาใส่ได้ทันที โดยไม่ต้องปิดเครื่องเลย เมื่อเราเอา HDD ตัวใหม่มาใส่
ระบบก็จะทำการสำรองข้อมูลไปที่ HDD ตัวใหม่เอง โดยอัตโนมัติ และข้อดีอีกอย่างคือ
มันสามารถเลือกที่จะอ่านข้อมูลจาก HDD ตัวไหนก็ได้ ทำให้มันอ่านข้อมูลได้เร็วขึ้น
ข้อเสีย เนื่องจากมันต้องเขียนข้อมูลลง HDD ถึง 2 ตัวต่อข้อมูล 1 ชุด
ทำให้ภาระในการเรียนข้อมูลมีมากขึ้นเป็น 2 เท่าเลย ทำให้เวลาในการเขียนข้อมูลมากกว่าปกติ
และระบบนี้ใช้เงินเยอะพอสมควร เพราะต้องใช้ HDD 2 ชุด ต่อข้อมูล 1 ชุด

RAID 0 + 1
RAID 0+1 คือการนำข้อดีของ RAID 0 และ RAID 1 มารวมกัน ทำให้มีการรวมเนื้อที่จาก HDD หลายๆ
ตัวเข้าด้วยกัน ละมีการทำสำเนาไปพร้อมกันด้วย โดยต้องนำ HDD มาแปลงเป็น RAID 0 จำนวน 2 ชุดก่อน
ทำให้ได้
Logic Drive ที่มีเนื้อที่ของ HDD มารวมกัน แล้วจึงสร้าง RAID 1 ขึ้นมาอีกทีจาก Logic Drive ทั้ง 2 ชุด
ข้อเสีย เปลือง HDD อย่างมาก และถ้า HDD ตัวไหนเสียไป อาจทำให้ Logic Drive เสีย และเจ้งทั้งระบบ

RAID 1 + 0
RAID 1+0 มีการทำงานเหมือนกับ RAID 0+1 เพียงแต่จะเริ่มสร้าง RAID 1 มาก่อน 2 ชุด
เพื่อทำการสำรองข้อมูลกันก่อน แล้วค่อยสร้าง RAID 0 ขึ้นมาอีกที เพื่อรวมข้อมูลทั้งหมดเข้าด้วยกัน
วิธีนี้เป็นที่นิยมมากกว่า RAID 0+1 อีกนะ (ผมก็ใช้ตัวนี้)
ข้อดี ถ้า HDD ตัวไหนเสีย จะไม่ทำให้ Logic Drive เสียไปด้วย
ข้อเสีย เปลือง HDD มากกว่า RAID 0+1 อีก ;-(

RAID 5
RAID 5 ได้นำข้อดีของ RAID แบบต่างๆ มารวมไว้ในตัวเอง คือ ราคา ประสิทธิภาพ
และความสามารถในการป้องกันข้อมูลสูญหาย เพราะ RAID แบบต่างๆ จะมีข้อดีไม่ครบทั้งหมด
คืออย่างมากก็ได้แค่
2 ใน 3 อย่าง RAID 1+0 ประสิทธิภาพดี ป้องกันข้อมูลได้ แต่แพงโคตร RAID 5 ต้องการ HDD 3 ตัวในการทำงาน
โดยนำเนื้อที่ของ HDD แต่ละตัวมาเก็บรวมกันเป็น 1 Logic Drive เหมือนการทำงานของ RAID 0 แล้วสร้าง
Parity Bit เพื่อใช้xxx้ข้อมูลของแต่ละ Drive ขึ้นมาโดยแยกออกไปเขียนใน Drive อื่นๆ เช่น Parity Bit
ของ
HddA จะนำไปไว้ที่ HddC ของ HddC ก็จะนำไปไว้ที่ HddB ส่วนของ HddB ก็จะนำไปไว้ที่ HddA วนกันไป 555
ข้อดี ข้อมูลไม่หายแน่นอน เพราะมีการเก็บ Parity ไว้ใน HDD แต่ละตัว แล้วความเร็วในการอ่านข้อมูล
ก็เยอะมากๆ ด้วย เนื่องจากมี HDD ถึง 3 ตัวนี่
ข้อเสีย เขียนข้อมูลได้ช้ามากๆ เนื่องจากต้องเขียนข้อมูลแล้ว ยังต้องไปเขีนยน Parity อีก
แล้วยังต้องใช้
HDD ถึง 3 ตัว ซึ่งเปลืองมาก (แต่ก็น้อยกว่า RAID 1+0) และอัตราความเร็วในการเขียนข้อมูลก็ช้ามากๆ

1080
ใช้ OS Debian 3.1
1.สั่งโหลด จาก mirror ในไทยครับ
โดยเพิ่มไปที่ /etc/apt/sources.list
แล้วสั่ง apt-get update แล้ว

#aptitude install snmpd
#aptitude install mrtg

แล้วมา config

#/etc/snmp/snmpd.conf

ให้เอา # ใส่หน้า คำสั่ง

com2sec paranoid default public

แล้วเอาเครื่องหมาย # ออกจากคำสั่ง

com2sec readonly default public

แล้วสั่ง daemon start

#/etc/init.d/snmpd restart

แล้วต่อไปมา config ไฟส์ mrtg บ้าง

แล้วพิมพ์ ตามนี้เพื่อทำการ สั่งให้สร้าง config


#cfgmaker --global 'options[_]: growright,bits' --global 'WorkDir: /home/golf/xxx' --output=/etc/mrtg.cfg public@127.0.0.1

การเพิ่มกราฟ นั้นไม่จำต้องลบไฟส์ในห้อง DocumentRoot ออกก็ได้น่ะครับแต่เพิ่มกราฟ establish กับ tcp
connection ดังนี้ในไฟส์ดังนี้ (ผมใช้เป็น OS Debian 3.1 ครับ)

#vi /etc/mrtg,cfg

โดยเพิ่ม

### 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]: <H1>CPU Analysis</H1>

### 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]: <H1>Memory Analysis</H1>

### New TCP Connection Monitoring (per minute) ###
Target[server.newconns]: tcpPassiveOpens.0&tcpActiveOpens.0: public@127.0.0.1
Title[server.newconns]: Newly Created TCP Connections
PageTop[server.newconns]: <H1>New TCP Connections</H1>
MaxBytes[server.newconns]: 10000000000
ShortLegend[server.newconns]: c/s
YLegend[server.newconns]: Conns / Min
LegendI[server.newconns]: In
LegendO[server.newconns]: Out
Legend1[server.newconns]: New inbound connections
Legend2[server.newconns]: New outbound connections
Options[server.newconns]: growright,nopercent,perminute

### Established TCP Connections ###
Target[server.estabcons]: tcpCurrEstab.0&tcpCurrEstab.0: public@127.0.0.1
Title[server.estabcons]: Currently Established TCP Connections
PageTop[server.estabcons]: <H1>Established TCP Connections</H1>
MaxBytes[server.estabcons]: 10000000000
ShortLegend[server.estabcons]:
YLegend[server.estabcons]: Connections
LegendI[server.estabcons]: In
LegendO[server.estabcons]:
Legend1[server.estabcons]: Established connections
Legend2[server.estabcons]:
Options[server.estabcons]: growright,nopercent,gauge

และสุดท้ายก็สั่ง คำสั่งข้างล่างนี้เพื่อให้แสดง output ออกมาที่ไฟส์ไหนถ้ารูปไม่ออกอาจเกิดจากการระบุ
output ผิดครับ

#indexmaker /etc/mrtg.cfg --columns=1 --output /home/golf/xxx/index.html

แล้วสั่ง mrtg 3 ครั้งสำหรับ Debian ครับ

#mrtg
#mrtg
#mrtg

แต่ถ้าเป็น ubuntu 6.06ให้สั่ง

#env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
#env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
#env LANG=C /usr/bin/mrtg /etc/mrtg.cfg

3 ครั้งน่ะครับ

จะได้กราฟตามนี้ครับที่ ===> http://www.saiyaithai.org/mrtg

Pages: 1 ... 70 71 [72] 73