實驗名稱:網絡的優化
配置步驟及思路:
一.給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.2.254
pc3:
ip 192.168.1.2
子網掩碼:255.255.255.0
網關:192.168.1.254
pc4:
ip 192.168.2.2
子網掩碼:255.255.255.0
網關:192.168.2.254
server1:
ip : 192.168.20.1
子網掩碼:255.255.255.0
網關:192.168.20.254
二.建立vlan並將端口加入設置trunk
1.在sw1上建立vlan將對應端口加入設置trunk
vlan batch 10 20 建立vlan10 20
interface Eth0/0/1 進入端口
port link-type aceess 設置access模式
port default vlan 10 將端口加入vlan
設置trunk:
interface Eth0/0/11 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/13 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
2.在sw2上建立vlan將對應端口加入設置trunk(要與sw1數據庫保持一致)
vlan batch 10 20 建立vlan10 20
interface Eth0/0/1 進入端口
port link-type aceess 設置access模式
port default vlan 20 將端口加入vlan
設置trunk:
interface Eth0/0/11 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/14 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
3.在sw3上建立vlan設置trunk(要與sw1,sw2數據庫保持一致)
vlan batch 10 20 建立vlan10 20
設置trunk:
interface Eth0/0/13 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/14 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/12 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
4.在sw4上建立vlan將對應端口加入設置trunk
vlan batch 10 20 建立vlan10 20
interface Eth0/0/1 進入端口
port link-type aceess 設置access模式
port default vlan 10 將端口加入vlan
設置trunk:
interface Eth0/0/11 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/13 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
5.在sw5上建立vlan將對應端口加入設置trunk(要與sw4數據庫保持一致)
vlan batch 10 20 建立vlan10 20
interface Eth0/0/1 進入端口
port link-type aceess 設置access模式
port default vlan 20 將端口加入vlan
設置trunk:
interface Eth0/0/11 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/14 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
6.在sw6上建立vlan設置trunk(要與sw4,sw5數據庫保持一致)
vlan batch 10 20 建立vlan10 20
設置trunk:
interface Eth0/0/13 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/14 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
interface Eth0/0/12 進入端口
port link-type trunk 設置trunk
port trunk allow-pass vlan all 容許全部vlan經過
三.修改STP(生成樹協議)
1.在sw1,sw2,sw3上修改
display stp 查看sw1,sw2,sw3的stp,肯定根交換機和非根交換機,找出阻塞端口(阻塞端口爲ALTE)
這裏查出阻塞端口爲Eth0/0/13,sw2爲根交換機,sw1爲非根交換機,爲了給交換機減壓將sw3設置成根交換機。配置以下:
stp priorty 0 修改優先級爲0(stp優先級越小越優先)
而後再輸入display stp 查看那個是根交換機和非根交換機。
2.在sw4,sw5,sw6上修改
display stp 查看sw1,sw2,sw3的stp,肯定根交換機和非根交換機,找出阻塞端口(阻塞端口爲ALTE)
這裏查出阻塞端口爲Eth0/0/13,sw2爲根交換機,sw1爲非根交換機,爲了給交換機減壓將sw3設置成根交換機。配置以下:
stp priorty 0 修改優先級爲0(stp優先級越小越優先)
而後再輸入display stp 查看那個是根交換機和非根交換機。
四.配置VRRP(至關於備份)
1.在sw3上將端口加入vlan10
interface GE0/01 進入端口
port link-type access 設置access模式
port default vlan 10 將vlan10加入端口
interface GE0/0/2 進入端口
port link-type access 設置access模式
port default vlan 10 將vlan10加入端口
interface GE0/0/3 進入端口
port link-type access 設置access模式
port default vlan 10 將vlan10加入端口
2.在sw6上將端口加入vlan20
interface GE0/01 進入端口
port link-type access 設置access模式
port default vlan 20 將vlan20加入端口
interface GE0/0/2 進入端口
port link-type access 設置access模式
port default vlan 20 將vlan20加入端口
interface GE0/0/3 進入端口
port link-type access 設置access模式
port default vlan 20 將vlan20加入端口
在路由器AR1配置vlan10的網關和ARRP
在接口下配置網關:
interface GE0/0/0
ip address 192.168.1.254
在接口下配置虛擬網關(VRRP)
interface GE0/0/0
vrrp 1 ip 192.168.1.250 開啓vrrp,配置虛擬網關
vrrp 1 priority 150 配置vrrp主機設備優先級。默認是100(vrrp優先級越大越優先)
vrrp vrid 1 track interface gi0/0/2 reduced 100 跟蹤端口 gi0/0/2 的狀態,若是 down, 則下降100,優先級變爲 50;
在路由器AR2上配置vlan10的網關和ARRP
在接口下配置網關:
interface GE0/0/0
ip address 192.168.1.253
在接口下配置虛擬網關(VRRP)
interface GE0/0/0
vrrp 1 ip 192.168.1.250 開啓vrrp,配置虛擬網關
vrrp 1 priority 130 配置vrrp主機設備優先級。默認是100(vrrp優先級越大越優先)
vrrp vrid 1 track interface gi0/0/2 reduced 100 跟蹤端口 gi0/0/2 的狀態,若是 down, 則下降100,優先級變爲 30;
在路由器AR3上配置vlan10的網關和ARRP
在接口下配置網關:
interface GE0/0/0
ip address 192.168.1.252
在接口下配置虛擬網關(VRRP)
interface GE0/0/0
vrrp 1 ip 192.168.1.250 開啓vrrp,配置虛擬網關
vrrp vrid 1 track interface gi0/0/2 reduced 100 跟蹤端口 gi0/0/2 的狀態,若是 down, 則下降100,優先級變爲 10;
在路由器AR1配置vlan20的網關和ARRP
在接口下配置網關:
interface GE0/0/0
ip address 192.168.2.254
在接口下配置虛擬網關(VRRP)
interface GE0/0/0
vrrp 1 ip 192.168.2.250 開啓vrrp,配置虛擬網關
vrrp 1 priority 150 配置vrrp主機設備優先級。默認是100(vrrp優先級越大越優先)
vrrp vrid 1 track interface gi0/0/2 reduced 100 跟蹤端口 gi0/0/2 的狀態,若是 down, 則下降100,優先級變爲 50;
在路由器AR2上配置vlan20的網關和ARRP
在接口下配置網關:
interface GE0/0/0
ip address 192.168.2.253
在接口下配置虛擬網關(VRRP)
interface GE0/0/0
vrrp 1 ip 192.168.2.250 開啓vrrp,配置虛擬網關
vrrp 1 priority 130 配置vrrp主機設備優先級。默認是100(vrrp優先級越大越優先)
vrrp vrid 1 track interface gi0/0/2 reduced 100 跟蹤端口 gi0/0/2 的狀態,若是 down, 則下降100,優先級變爲 30;
在路由器AR3上配置vlan20的網關和ARRP
在接口下配置網關:
interface GE0/0/0
ip address 192.168.2.252
在接口下配置虛擬網關(VRRP)
interface GE0/0/0
vrrp 1 ip 192.168.2.250 開啓vrrp,配置虛擬網關
vrrp 1 priority 110 配置vrrp主機設備優先級。默認是100(vrrp優先級越大越優先)
vrrp vrid 1 track interface gi0/0/2 reduced 100 跟蹤端口 gi0/0/2 的狀態,若是 down, 則下降100,優先級變爲 10;
而後在pc機上將網管改爲VRRP的虛擬網關
pc1:
網關:192.168.1.250
pc2:
網關:192.168.2.250
pc3:
網關:192.168.1.250
pc4:
網關:192.168.2.250
最後在pc機上ping修改後的網關看能拼通不,能拼通說明VRRP建立成功
五。配置交換機和路由器間的網址
路由器(路由器上不能建立vlan只能在端口下配置ip):
AR1:
interface GE0/0/2 進入端口
ip address 192.168.12.1 255.255.255.0 配置ip
AR2:
interface GE0/0/2 進入端口
ip address 192.168.13.1 255.255.255.0 配置ip
AR3:
interface GE0/0/3 進入端口
ip address 192.168.14.1 255.255.255.0 配置ip
交換機sw7上(交換機上不能在端口配置ip,只能在vlan的虛擬端口配置ip):
1.建立vlan 30 40 50 60
vlan batch 30 40 50 60
2.在vlan上的虛擬端口配置ip
interface vlan 30
p address 192.168.12.2 255.255.255.0
interface vlan 40
ip address 192.168.13.2 255.255.255.0
interface vlan 50
p address 192.168.14.2 255.255.255.0
interface vlan 60
ip address 192.168.19.1 255.255.255.0
路由器AR4(路由器上不能建立vlan只能在端口下配置ip)
interface GE0/0/1 進入端口
ip address 192.168.19.2 255.255.255.0 配置ip
interface GE0/0/0
ip address 192.168.20.254 255.255.255.0 配置server1的網關
六.建立OSPF區域
在路由器AR1上:
ospf {1} 建立ospf區域(id默認是1,可寫可不寫)
area 0 建立主區域0(0是主幹區域,其它爲非主幹區域)
network 192.168.1.254 創建鄰居表
network 192.168.2.254 創建鄰居表
network 192.168.12.1 創建鄰居表
在路由器AR2上:
ospf {1} 建立ospf區域(id默認是1,可寫可不寫)
area 0 建立主區域0(0是主幹區域,其它爲非主幹區域)
network 192.168.1.253 創建鄰居表
network 192.168.2.253 創建鄰居表
network 192.168.13.1 創建鄰居表
在路由器AR3上:
ospf {1} 建立ospf區域(id默認是1,可寫可不寫)
area 0 建立主區域0(0是主幹區域,其它爲非主幹區域)
network 192.168.1.252 創建鄰居表
network 192.168.2.252 創建鄰居表
network 192.168.14.1 創建鄰居表
在交換機sw7上:
ospf {1} 建立ospf區域(id默認是1,可寫可不寫)
area 0 建立主區域0(0是主幹區域,其它爲非主幹區域)
network 192.168.12.2 創建鄰居表
network 192.168.13.2 創建鄰居表
network 192.168.14.2 創建鄰居表
network 192.168.19.1 創建鄰居表
在路由器AR4上:
ospf {1} 建立ospf區域(id默認是1,可寫可不寫)
area 0 建立主區域0(0是主幹區域,其它爲非主幹區域)
network 192.168.19.2 創建鄰居表
network 192.168.20.254 創建鄰居表
查看鄰居表的命令:
display ospf peer 查看ospf鄰居表詳細信息
display ospf brief 查看本地設備的ospf相關信息
七。驗證,測試
拿任何一臺pc機訪問其餘主機實現全網互通
而後在路由和交換機之間進任意一個端口輸入shutdown,讓此路不通看是否還能拼通(內網)
命令:ping x.x.x.x x.x.x.x表明ip地址數據庫