網絡中有兩個Linux Router: (1), Master(eth0:192.168.1.10/24接外網; eth1:192.168.3.1/24接內網) (2), Backup(eth0:192.168.2.10/24接外網; eth1:192.168.3.2/24接內網) 內網的IP地址段為192.168.3.0/24,網關(V-Gate)為192.168.3.3/24,記住192.168.3.3/24這個地址是在Keepalived啟動時生效的。 首先我們在Linux Router Master上安裝keepalived-1.1.6.tar.gz (1)、下載keepalived-1.1.6.tar.gz (http://www.keepalived.org) (2)、解壓縮: #tar zxvf keepalived-1.1.6.tar.gz (3)編譯keepalived #cd keepalived-1.1.6 #./configure –prefix=/usr/local/keepalived #make (4)安裝keepalived #make install (5)配置Linux Router Master的VRRP #vi /usr/local/keepalived/etc/keepalived/keepalived.conf 內容如下: vrrp_instance VI_1 { state MASTER interface eth1 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.3.3 } }
更多內容請看Linux路由器的實現 Linux路由相關文章用 交換機與路由器密碼恢復專題,或在Linux Router Backup上安裝keepalived的方法是相同的,不同的是配置文件/usr/local/keepalived/etc/keepalived/keepalived.conf,如下: vrrp_instance VI_1 { state BACKUP interface eth1 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.3.3 } } 在啟動Master上的keepalived之前,我們先看一下Master上eth1的情況: # ip add show eth1 8: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:e0:4c:3a:d7:25 brd ff:ff:ff:ff:ff:ff inet 192.168.3.1/24 brd 192.168.3.255 scope global eth1 inet6 fe80::2e0:4cff:fe3a:d725/64 scope link 我們看到只有一個IP地址:192.168.3.1/24,現在我們啟動Master上的keepalived: #/usr/local/keepalived/sbin/keepalived –D –f /usr/local/keepalived/etc/keepalived/keepalived.conf 現在我們再看一下Master上eth1的情況:
# ip add show eth1 8: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:e0:4c:3a:d7:25 brd ff:ff:ff:ff:ff:ff inet 192.168.3.1/24 brd 192.168.3.255 scope global eth1 inet 192.168.3.3/32 scope global eth1 inet6 fe80::2e0:4cff:fe3a:d725/64 scope link 我們看到有兩個IP地址,其中一個就是V-Gate:192.168.3.3/32 用同樣的方法啟動Backup上的keepalived: #/usr/local/keepalived/sbin/keepalived –D –f /usr/local/keepalived/etc/keepalived/keepalived.conf 這樣,當Master失效時,Backup就會通過MultiCast地址:224.0.0.18這個組播地址,獲得這個消息,並將192.168.3.3這個地址接管過來。 總結,請你注意一下我們這個實驗的題目“利用Keepalived的VRRP功能實現簡單的路由器備份”,而不是路由備份。我們這個實驗的目的,是讓大家熟悉VRRP協議和如何利用Keepalived實現VRRP協議。
更多內容請看Linux路由器的實現 Linux路由相關文章用 交換機與路由器密碼恢復專題,或