แสดงกระทู้

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.


Messages - golfreeze

Pages: 1 ... 141 142 [143] 144 145 146
2131
all application on unix knowledges by golfreeze / Re: install ipvs loadbalance in debian
« on: มกราคม 23, 2011, 12:46:47 AM »
check package วิ่งผ่าน firewall โดย command line
#watch -n 1 "iptables -t nat -L -xv"
check load วิ่งเข้า load balance ดู connection ต่างๆ
#watch -n 1"ipvsadm -L -n --stats"

2132
all application on unix knowledges by golfreeze / Re: install ipvs loadbalance in debian
« on: มกราคม 23, 2011, 12:46:36 AM »
ถ้าใครใช้เป็น debian 4.0 R1 เป็นแบบ 64 bit ก็ตั้ง

deb http://ftp.thaios.net/debian/etch main
deb-src http://ftp.thaios.net/debian/etch main

สำหรับ kernel ที่เป็น verion "lenny"
ตั้งไปที่
deb http://ftp.de.debian.org/debianlenny main
deb-src http://ftp.de.debian.org/debianlenny main

2134
all application on unix knowledges by golfreeze / Re: install ipvs loadbalance in debian
« on: มกราคม 23, 2011, 12:46:02 AM »


สำหรับ network ที่ทำก็ตามรูป นี้น่ะครับ

2135
all application on unix knowledges by golfreeze / Re: install ipvs loadbalance in debian
« on: มกราคม 23, 2011, 12:45:28 AM »
ถ้าทำแล้ว มี error สั่งให้ start service ไม่ได้ ตอน ดู
สั่ง /etc/init.d/heartbeat stop
/etc/init.d/heartbeat start
Ldirectord is stopped for /etc/ha.d/ldirectord.cf
แล้วจะเกิดเป็น heartbeat failure [rc=xxx] failed

ให้เข้าไป check ที่ไฟล์ config เพราะอาจจะ กำหนด ตัว ชื่อ ethX ผิดในไฟล์
Ldirectord.cf , ha.cf
แล้วสั่ง start อีกรอบ ดู จะได้ครับ

2136
all application on unix knowledges by golfreeze / Re: install ipvs loadbalance in debian
« on: มกราคม 23, 2011, 12:45:10 AM »
อีกคำสั่งที่เอาไว้ check ip addr ของ virtual ip คือ
#ip addr sh

ก็จะมีดังนี้ ครับ

2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:11:25:f1:ef:7d brd ff:ff:ff:ff:ff:ff
inet 10.0.1.149/23 brd 10.0.1.255 scope global eth0
inet 10.0.1.152/23 brd 10.0.1.255 scope global secondary eth0
inet6 2001:d90:10:101:211:25ff:fef1:ef7d/64 scope global dynamic
valid_lft 2591980sec preferred_lft 604780sec
inet6 fe80::211:25ff:fef1:ef7d/64 scope link
valid_lft forever preferred_lft forever
3: eth2: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:80:48:13:56:1c brd ff:ff:ff:ff:ff:ff
inet 172.16.0.2/29 brd 172.16.0.7 scope global eth2
inet6 fe80::280:48ff:fe13:561c/64 scope link
valid_lft forever preferred_lft forever

2137
all application on unix knowledges by golfreeze / Re: install ipvs loadbalance in debian
« on: มกราคม 23, 2011, 12:44:57 AM »
สำหรับ ipvsadm version 1.2.1 ถ้าท่านไหนใช้ ให้ load balance ตัว
pop3 กับ imap protocol ล่ะก็ต้องลง patch module เพิ่มด้วยน่ะครับ

ของผมใช้งานเป็น debian 4.0 R1 ก็ search packet โดย

#apt-cache search ldirectord
ถ้ามี ก็สั่ง install โดย
#apt-get install ldirectord2
ซึ่งจะทำการ โหลด module ของ libmail-pop3client-perl
ซึ่งจะทำให้สามารถ load balance application ที่เป็น pop กับ imap ได้ครับ

เสร็จก็ทำการ restart service ipvs 1 รอบโดย

#/etc/init.d/heartbeat restart

แล้วลอง ipvsadm -l ดูครับ load ก็จะทำการ balance ไปที่ pop client

golfreeze[at]packetlove.com

2138
#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 ครับ และคำแนะนำ อิอิ

2140
วันนี้ ลอง tool อีกตัวหนึ่งครับ คือ macchanger

ใน debian ก็ลงเป็น
#apt-get install macchanger

เสร็จแล้ว ก็ เริ่ม ใส่โดย
#macchanger --m xxxxxxx ชื่อinterface

แค่นี้ก็จัดการ ปลอม mac address ของ wifi ได้แล้วครับ อิอิ

2141
วิธีการ set interface ให้รับ ip แบบ dhcp ใน debian ครับ

#dhclient ชื่อinterface

หรือถ้ายังไม่ทราบว่า interface ไหนใช้ได้บ้างก็ใช้คำสั่ง

#mii-tools

ครับ

2142
อิอิ วันก่อนไปแข่งงาน 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

2143
###sed ในกรณีเขียน ให้เปลี่ยน ตัวแปรไปด้วย

#!/bin/sh

change="xxxx"

less xxx.txt | sed 's/xxxx/'$change'/g' > xxx_new.txt

================

ต้องใส่ เครื่องหมาย ' ' ในตัวแปรด้วยน่ะครับ เป็น '$change' แบบนี้ครับผม

2144
##Count string + uniq word
less pop3d-ssl_list_grep_k | awk -F '@' '{print $2}' | sort | uniq -c | sort -n

##Check and find content of email
find ./ -type f -exec /bin/grep "487C2369.5070808@arc.net.my";; {} /dev/null \;

2145
#free | cut -d " " -f
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,28

#grep -L -r 'Subject: Shi' .

#find /home/gigi -name '*.c' -print | xargs grep 'hello' /dev/null

#sudo find / -type f -name *.jpg -exec cp {} . \;

find . -type f -size +10000 -exec ls -al {} \;
find . -atime +1 -type f -exec mv {} TMP \; # mv files older then 1 day to dir TMP
find . -name "-F" -exec rm {} \; # a script error created a file called -F
find . -exec grep -i "vds admin" {} \;
find . \! -name "*.Z" -exec compress -f {} \;
find . -type f \! -name "*.Z" \! -name ".comment" -print | tee -a
/tmp/list
find . -name *.ini
find . -exec chmod 775 {} \;
find . -user xuser1 -exec chown -R user2 {} \;
find . -name ebtcom*
find . -name mkbook
find . -exec grep PW0 {} \;
find . -exec grep -i "pw0" {} \;
find . -atime +6
find . -atime +6 -exec ll | more
find . -atime +6 -exec ll | more \;
find . -atime +6 -exec ll \;
find . -atime +6 -exec ls \;
find . -atime +30 -exec ls \;
find . -atime +30 -exec ls \; | wc -l
find . -name auth*
find . -exec grep -i plotme10 {};
find . -exec grep -i plotme10 {} \;
find . -ls -exec grep 'PLOT_FORMAT 22' {} \;
find . -print -exec grep 'PLOT_FORMAT 22' {} \;
find . -print -exec grep 'PLOT_FORMAT' {} \;
find . -print -exec grep 'PLOT_FORMAT' {} \;
find ./machbook -exec chown 184 {} \;
find . \! -name '*.Z' -exec compress {} \;
find . \! -name "*.Z" -exec compress -f {} \;
find /raid/03c/ecn -xdev -type f -print
find /raid/03c/ecn -xdev -path -type f -print
find / -name .ssh* -print | tee -a ssh-stuff
find . -name "*font*"
find . -name hpmcad*
find . -name *fnt*
find . -name hp_mcad* -print
find . -grep Pld {} \;
find . -exec grep Pld {} \;
find . -exec grep Pld {} \;
find . -exec grep PENWIDTH {} \; | more
find . -name config.pro
find . -name config.pro
find /raid -type d ".local_sd_customize" -print
find /raid -type d -name ".local_sd_customize" -print
find /raid -type d -name ".local_sd_customize" -ok cp
/raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} \;
find /raid -type d -name ".local_sd_customize" -exec cp
/raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} \;
find . -name xeroxrelease
find . -exec grep xeroxrelease {} \;
find . -name xeroxrelease
find . -name xeroxrelease* -print 2>/dev/null
find . -name "*release*" 2>/dev/null
find / -name "*xerox*" 2>/dev/null
find . -exec grep -i xeroxrelease {} \;
find . -print -exec grep -i xeroxrelease {} \;
find . -print -exec grep -i xeroxrelease {} \; > xeroxrel.lis
find . -exec grep -i xeroxrel {} \;
find . -print -exec grep -i xeroxrel {} \;
find . -print -exec grep -i xeroxrel {} \; | more
find /raid/03c/inwork -xdev -type f -print >> /raid/04d/user_scripts/prt_list.tmp
find . -exec grep '31.53' {} \;
find . -ls -exec grep "31/.53" {} \; > this.lis
find . -print -exec grep "31/.53" {} \; > this.lis
find . -print -exec grep 31.53 {} \; > this.lis
find . -exec grep -i pen {} /;
find . -exec grep -i pen {} \;
find . -print -exec grep -i pen {} \; | more
find . -exec grep -i pen {} \;
find . -atime +6 -exec ll | more \;
find . -atime +6 -exec ll \;
find . -atime +6 -exec ls \;
find . -atime +30 -exec ls \;
find . -atime +30 -exec ls \; | wc -l
find . \! -name '*.Z' -exec compress -f {} \;
find . -name 'cache*' -depth -exec rm {} \;
find . -name 'cache*' -depth -print | tee -a /tmp/cachefiles
find . -name 'cache[0-9][0-9]*' -depth -print | tee -a /tmp/cachefiles
find . -name 'hp_catfile' 'hp_catlock' -depth -print | tee -a /tmp/hp.cats
find . -name 'hp_catfile' -name 'hp_catlock' -depth -print | tee -a /tmp/hp.cats
find . -name 'hp_cat*' -depth -print | tee -a /tmp/hp.cats
find . -name 'hp_cat[fl]*' -depth -print | tee -a /tmp/hp.cats
find /raid -name 'hp_cat[fl]*' -depth -print
find . \! -name '*.Z' -exec compress -f {} \;
find . -name '*' -exec compress -f {} \;
find . -xdev -name "wshp1*" -print
find . -xdev -name "wagoneer*" -print
find . -name "xcmd" -depth -print
find /usr/contrib/src -name "xcmd" -depth -print
find /raid -type d -name ".local_sd_customize" -exec ls {} \;
find /raid -type d -name ".local_sd_customize" \
-exec cp /raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {}
\;

Pages: 1 ... 141 142 [143] 144 145 146