FreeBSD CARP ( Common Access Redundancy Protocol ) 設定與測試方法

測試前說明:
使用三台主機作測試,兩台Server,一台Client,
dk.oio.idv.tw 192.168.78.1
dk1.oio.idv.tw 192.168.78.2
dk2.oio.idv.tw 192.168.78.3
dk3.oio.idv.tw client

1、先將兩台Server,於kernel中,增加一個device carp,再重新編譯kernel。
device carp

2、於dk1、dk2,執行以下步驟:
a、device使用carp portocol

#sysctl net.inet.carp.allow=1
執行後:
net.inet.carp.allow: 0 -> 1

b、建立一個carp5的interface

#ifconfig carp5 create
執行後:
carp5: flags=8 mtu 1500

c、設定carp5 VHID IP Netmask,** VHID是重點:這會影嚮carp5 mac address

#ifconfig carp5 vhid 5 192.168.78.1 255.255.240.0

dk1 查視 carp5 interface
#ifconfig carp5
carp5: flags=49 mtu 1500
inet 192.168.78.1 netmask 0xffffff00
carp: MASTER vhid 5 advbase 1 advskew 0

/var/log/message
dk1 kernel: em0: promiscuous mode enabled

dk2 查視 carp5 interface
#ifconfig carp5
carp5: flags=49 mtu 1500
inet 192.168.78.1 netmask 0xffffff00
carp: BACKUP vhid 5 advbase 1 advskew 0

/var/log/message
dk2 kernel: em0: promiscuous mode enabled

dk3 client ping dk.oio.idv.tw 測試封包不中斷。

dk1
#ifconfig carp5 down
carp5: flags=8 mtu 1500
inet 192.168.78.1 netmask 0xffffff00
carp: INIT vhid 5 advbase 1 advskew 0

dk2
1、/var/log/message 會先收到
dk2 kernel: arp_rtrequest: bad gateway 192.168.78.241 (!AF_LINK)

2、會自動變成Master
carp5: flags=49 mtu 1500
inet 192.168.78.1 netmask 0xffffff00
carp: MASTER vhid 5 advbase 1 advskew 0

3、會自動接起 dk.oio.idv.tw,文件說1/256 sec

自動接下送往192.168.78.1封包
--- dk.oio.idv.tw ping statistics ---
509 packets transmitted, 509 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.100/0.222/0.424/0.051 ms

dk1 重啟後,並不會自動轉為Master
#ifconfig carp5 up

/var/log/message 會收到
dk1 kernel: arp_rtrequest: bad gateway 192.168.78.241 (!AF_LINK)

#ifconfig carp5
carp5: flags=49 mtu 1500
inet 192.168.78.241 netmask 0xffffff00
carp: BACKUP vhid 5 advbase 1 advskew 0


如希望dk1,恢復後可以自動轉為Master,則須在dk1、dk2執行以下指令
#sysctl net.inet.carp.preempt=1



引用資料:http://www.openbsd.org/faq/pf/carp.html#carpconfig

Posted in 標籤: |

0 意見: