配置步驟及思路:
一.配置pc機的ip
pc1:
ip 192.168.1.1
子網掩碼:255.255.255.0
網關:192.168.1.254
pc2:
ip 192.168.2.1
子網掩碼:255.255.255.0
網關:192.168.1.254
pc3:
ip 192.168.3.1
子網掩碼:255.255.255.0
網關:192.168.1.254
pc4:
ip 192.168.4.1
子網掩碼:255.255.255.0
網關:192.168.1.254
二.建立vlan並將端口加入設置trunk
建立vlan並將端口加入:服務器
vlan batch 10 20 30 40 建立vlan10,20.30,40 interface GE0/0/1 進入端口 port link-type access 設置access模式 port default vlan 10 將vlan10 加入 interface GE0/0/2 進入端口 port link-type access 設置access模式 port default vlan 20 將vlan20 加入 interface GE0/0/5 進入端口 port link-type access 設置access模式 port default vlan 10 將vlan30 加入 interface GE0/0/6 進入端口 port link-type access 設置access模式 port default vlan 20 將vlan40 加入 設置trunk: sw1: interface GE0/0/3 進入端口 port link-type trunk 設置trunl模式 port trunk allow-pass vlan all 容許全部vlan經過 interface GE0/0/4 進入端口 port link-type trunk 設置trunl模式 port trunk allow-pass vlan all 容許全部vlan經過 sw2: interface GE0/0/1 進入端口 port link-type trunk 設置trunl模式 port trunk allow-pass vlan all 容許全部vlan經過 sw3: interface GE0/0/1 進入端口 port link-type trunk 設置trunl模式 port trunk allow-pass vlan all 容許全部vlan經過 三.配置網關 在sw2上: interface vlan 10 進入vlan10的虛擬端口 ip address 192.168.1.254 255.255.255.0 配置ip interface vlan 20 進入vlan20的虛擬端口 ip address 192.168.2.254 255.255.255.0 配置ip interface vlan 30 進入vlan30的虛擬端口 ip address 192.168.3.254 255.255.255.0 配置ip interface vlan 40 進入vlan20的虛擬端口 ip address 192.168.4.254 255.255.255.0 配置ip 在sw3上: 在sw3上配置網關主要起一個備份的做用,防止sw2上的鏈路中斷 interface vlan 10 進入vlan10的虛擬端口 ip address 192.168.1.253 255.255.255.0 配置ip interface vlan 20 進入vlan20的虛擬端口 ip address 192.168.2.253 255.255.255.0 配置ip interface vlan 30 進入vlan30的虛擬端口 ip address 192.168.3.253 255.255.255.0 配置ip interface vlan 40 進入vlan20的虛擬端口 ip address 192.168.4.253 255.255.255.0 配置ip 四.配置VRRP(虛擬網關) 在sw2上: interface vlan 10 進入vlan10的虛擬端口 vrrp vrip 1 virtual-ip 192.168.1.250 配置虛擬網關 vrrp vrip 1 priority 150 設置優先級 vrrp vrip 1 track interface GE0/0/2 reduces 100 跟蹤端口GE0/0/2的端口狀態,若是down掉,則下降100,變爲50 interface vlan 20 進入vlan20的虛擬端口 vrrp vrip 1 virtual-ip 192.168.2.250 配置虛擬網關 vrrp vrip 1 priority 150 設置優先級 vrrp vrip 1 track interface GE0/0/2 reduces 100 跟蹤端口GE0/0/2的端口狀態,若是down掉,則下降100,變爲50 interface vlan 30 進入vlan30的虛擬端口 vrrp vrip 1 virtual-ip 192.168.3.250 配置虛擬網關 interface vlan 40 進入vlan40的虛擬端口 vrrp vrip 1 virtual-ip 192.168.4.250 配置虛擬網關 在sw3上: interface vlan 10 進入vlan10的虛擬端口 vrrp vrip 1 virtual-ip 192.168.1.250 配置虛擬網關 interface vlan 20 進入vlan20的虛擬端口 vrrp vrip 1 virtual-ip 192.168.2.250 配置虛擬網關 interface vlan 30 進入vlan30的虛擬端口 vrrp vrip 1 virtual-ip 192.168.3.250 配置虛擬網關 vrrp vrip 1 priority 150 設置優先級 vrrp vrip 1 track interface GE0/0/2 reduces 100 跟蹤
GE0/0/2的端口狀態,若是down掉,則下降100,變爲50
interface vlan 40 進入vlan40的虛擬端口
vrrp vrip 1 virtual-ip 192.168.4.250 配置虛擬網關
vrrp vrip 1 priority 150 設置優先級
vrrp vrip 1 track interface GE0/0/2 reduces 100 跟蹤GE0/0/2的端口狀態,若是down掉,則下降100,變爲50
若是兩條線路都沒故障v10,v20從左面走,v30.v40從右面走既能夠實現備份功能又能減輕單臺服務器的壓力
五.驗證,測試
1.把pc機上的網關修改成虛擬網關
pc1:
ip 192.168.1.1
子網掩碼:255.255.255.0
網關:192.168.1.250
pc2:
ip 192.168.2.1
子網掩碼:255.255.255.0
網關:192.168.1.250
pc3:
ip 192.168.3.1
子網掩碼:255.255.255.0
網關:192.168.1.250
pc4:
ip 192.168.4.1
子網掩碼:255.255.255.0
網關:192.168.1.250
2.在命令行ping本身虛擬網關
ping 192.168.x.250 x表明不一樣網段
而後拼其它主機看是否能全網拼通
能拼成功說明實驗成功ide