วันจันทร์ที่ 12 มีนาคม พ.ศ. 2555

Ethernet bonding on Debianv

Ethernet bonding on Debian
โดย: โสทร รอดคงที่  srk@hospital-os.com
วันที่: วันที่เขียน 22 สิงหาคม 2548
ปรังปรุงจาก: -
ปรับปรุงล่าสุด:  -
แหล่งข้อมูล:
http://glasnost.beeznest.org/articles/179http://www.jebus.ca/Linux/ethernet_bonding.php
http://lists.debian.org/debian-user-spanish/2004/05/msg00220.html 


เกริ่นนำ:


หลังจากที่ได้ทำลองทำ Ethernet Bonding บน Red Hat สำเร็จ ก็ได้ทดลองทำ บน Debian บ้าง
ปรากฏว่ามีอะไรหลายอย่างที่ไม่เหมือน Red Hat เอกสารบางอย่างที่ค้นมาทำไม่สำเร็จก็มี
ที่ทดลองทำสำเร็จ มี 2 วิธีซึ่งไม่ทราบเหมือนกันว่าอันไหนจะดีกว่ากัน ที่เขียนไม่ได้หวัง ว่าจะให้ทำ bonding ได้นะครับ
คิดว่ามาเริ่มต้นเรียนรู้ Debian กันดีกว่า

สิ่งจำเป็น:คอมพิวเตอร์ ใส่ Lan Card 2 อัน ติดตั้ง linux Debian

ขั้นตอนการทำ

ทั้งสองวิธีมีวิธีการทำที่เหมือนกันคือ

ติดตั้ง package ifenslave-2.4 (kernel 2.4) ifenslave-2.6 (kernel 2.6)
ใครใช้ kernel ไหนอยู่ก็ติดตั้ง ตาม Kernel นั้นนะครับ
การติดตั้ง เครื่องที่จะติดตั้งต้องสามารถใช้ งาน Internet ได้

แก้ไฟล์ /etc/apt/sources.list เพื่อระบุที่ที่เราจะไปดาวน์โหลดโปรแกรม
vi /etc/apt/sources.list
เพิ่ม
deb http://ftp.au.debian.org/debian/ stable main
deb-src http://ftp.au.debian.org/debian/ stable main
                                                                               
deb http://security.debian.org/ stable/updates main


#ผมชอบดาวน์โหลดจากออสเตรเลีย รู้สึกว่าเร็วกว่า

apt-get update

apt-get install ifenslave-2.4หรือ
apt-get install ifenslave-2.6
แค่นี้ก็ติดตั้งเสร็จแล้ว
การใช้งาน apt-get ดูรายละเอียดจากของพี่อุทัยนะครับ


แก้ไฟล์ /etc/modules.conf
เพิ่มบรรทัดนี้เข้าไป
alias bond0 bonding
options bonding maxbonds=4 mode=6 miimon=100 หรือ
/etc/modprobe.d/arch/i386
alias bond0 bonding
options bonding mode=1 miimon=100 downdelay=200 updelay=200


option ต่างๆ ดูได้จาก

http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/bonding.txt
ยังไม่ชำนาญ Debian นะครับ ไม่สามารถอะธิบายได้ว่า
/etc/modules.conf และ /etc/modprobe.d/arch/i386 มีหน้าที่ยังไง
ดูๆ แล้วก็เหมือน ๆ กัน ใครเซียน Debian ก็บอกมาหน่อยก็แล้วกันนะครับ


วิธีการทำ Bonding 2 วิธีนี้ อันนี้เป็นตัวอย่าง
ประยุกต์ใช้งานเอาเองนะครับ

วิธีที่ 1
สร้างไฟล์ rc.local ใน /etc/init.d
cd /etc/init.d
touch rc.local
แล้วก็ทำ link
ln -s /etc/init.d/rc.local /etc/rc2.d/S99rc.local
chmod 755 rc.local


แก้ไฟล์ /etc/init.d/rc.local
อาจจะใช้ VI หรือ Text Editor ที่ ท่านถนัด
vi rc.local

โดยเพิ่มข้อคความเหล่านี้

/etc/init.d/networking stop
modprobe bonding max_bonds=2
ifconfig bond0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up
ifconfig eth0 up
ifconfig eth1 up
ifenslave bond0 eth0 eth1
route add default gw 192.168.1.254

วิธีที่ 2

แก้ไฟล์ /etc/network/interface


auto bond0
iface bond0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
pre-up ifconfig eth0 up
pre-up ifconfig eth1 up
up ifenslave bond0 eth0 eth1
down ifenslave -d bond0 eth0 eth1
post-down ifconfig eth0 down
post-down ifconfig eth1 down


เสร็จแล้วครับทั้งสองวิธีนี้สามารถใช้งานได้

ไม่มีความคิดเห็น:

แสดงความคิดเห็น