CCNA綜合實驗,vlan,vlan間路由,vtp,HSRP,PVST,DHCP。

wKioL1WhjKbSrda3AAIkeZPbChQ809.jpg

本實驗綜合了,vlan間路由,DHCP,VTP,PVST,HSRP。本實驗目的就是把這幾種協議融合一起實現主機互通,相信實際運用這種例子還是很多見的。希望大家看看,有錯誤的請指正。也是辛苦了好長時間才弄到這上面的。





第一步:先把每個交換機上各個接口起TRUNK模式(除了接PC的接口)


SW1


Switch>

Switch>

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname SW1

SW1(config)#int range fa 0/8-11

SW1(config-if-range)#swi

SW1(config-if-range)#switchport r

SW1(config-if-range)#switchport t

SW1(config-if-range)#switchport trunk en

SW1(config-if-range)#switchport trunk encapsulation d

SW1(config-if-range)#switchport trunk encapsulation dot1q 

SW1(config-if-range)#swi

SW1(config-if-range)#switchport mode t

SW1(config-if-range)#switchport mode trunk


這種方法就是把各個接口都封裝成dot1q,思科三層交換機端口對於vlan間路由默認有兩種封裝協議即802.1q,也就是dot1q,另一種協議就是ISL協議,爲思科私有。若不封裝特定協議就直接打switchport mode trunk的話,三層交換機自身將無法選擇協議去封裝,這樣就無法把端口設爲TRUNK模式。必須指定一種協議,這裏我們用公用協議dot1q。


還有一種方法也可起TRUNK


SW1(config)#int range fa 0/8-11

SW1(config-if-range)#swi

SW1(config-if-range)#switchport mode ac

SW1(config-if-range)#switchport mode access 

SW1(config-if-range)#switchport mode t

SW1(config-if-range)#switchport mode trunk 


這種方法就是先把端口設爲access接口模式,這樣就默認封裝了dot1q協議,也能起TRUNK。

思科二層交換機默認封裝的是dot1q協議。所以可以直接TRUNK。


SW2


Switch>

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname SW2

SW2(config)#int range fa 0/8-11

SW2(config-if-range)#swi

SW2(config-if-range)#switchport t

SW2(config-if-range)#switchport trunk e

SW2(config-if-range)#switchport trunk encapsulation d

SW2(config-if-range)#switchport trunk encapsulation dot1q 

SW2(config-if-range)#swi

SW2(config-if-range)#switchport mode t

SW2(config-if-range)#switchport mode trunk 

SW2(config-if-range)#


SW3


Switch>

Switch>

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname SW3

SW3(config)#int range fa 0/10-11

SW3(config-if-range)#swi

SW3(config-if-range)#switchport mode t

SW3(config-if-range)#switchport mode trunk 


SW4


Switch>

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname SW4

SW4(config)#int range fa 0/10-11

SW4(config-if-range)#swi

SW4(config-if-range)#switchport mode t

SW4(config-if-range)#switchport mode trunk 


第二步:分別把SW1和SW2的fa0/8和fa0/9端口進行端口匯聚。


SW1:


SW1(config)#

SW1(config)#

SW1(config)#int range fa 0/8-9

SW1(config-if-range)#channel-g

SW1(config-if-range)#channel-group 1 ?

  mode  Etherchannel Mode of the interface

SW1(config-if-range)#channel-group 1 mode ?

  active     Enable LACP unconditionally

  auto       Enable PAgP only if a PAgP device is detected

  desirable  Enable PAgP unconditionally

  on         Enable Etherchannel only

  passive    Enable LACP only if a LACP device is detected

SW1(config-if-range)#channel-group 1 mode on

SW1(config-if-range)#

Creating a port-channel interface Port-channel 1

%LINK-5-CHANGED: Interface Port-channel 1, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel 1, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/8, changed state to down


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/8, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/9, changed state to down


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/9, changed state to up




SW2:


SW2(config)#

SW2(config)#

SW2(config)#int range fa 0/8-9

SW2(config-if-range)#channel-g

SW2(config-if-range)#channel-group 1 mode on 把這兩個端口加入匯聚組1

SW2(config-if-range)#

Creating a port-channel interface Port-channel 1


%LINK-5-CHANGED: Interface Port-channel 1, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel 1, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/8, changed state to down


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/8, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/9, changed state to down


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/9, changed state to up


咱們在特權模式下來查看一下


SW2#

SW2#show et

SW2#show etherchannel s

SW2#show etherchannel summary 

Flags:  D - down        P - in port-channel

        I - stand-alone s - suspended

        H - Hot-standby (LACP only)

        R - Layer3      S - Layer2

        U - in use      f - failed to allocate aggregator

        u - unsuitable for bundling

        w - waiting to be aggregated

        d - default port



Number of channel-groups in use: 1

Number of aggregators:           1


Group  Port-channel  Protocol    Ports

------+-------------+-----------+----------------------------------------------


1      Po1(SU)           -      Fa0/8(P) Fa0/9(P) 


怎麼樣,S表示是二層匯聚,U表示已經應用,P代表已加入匯聚組1了


再來查查SW1的匯聚情況


SW1#

SW1#show et

SW1#show etherchannel s

SW1#show etherchannel summary 

Flags:  D - down        P - in port-channel

        I - stand-alone s - suspended

        H - Hot-standby (LACP only)

        R - Layer3      S - Layer2

        U - in use      f - failed to allocate aggregator

        u - unsuitable for bundling

        w - waiting to be aggregated

        d - default port



Number of channel-groups in use: 1

Number of aggregators:           1


Group  Port-channel  Protocol    Ports

------+-------------+-----------+----------------------------------------------


1      Po1(SU)           -      Fa0/8(P) Fa0/9(P) 


OK,做匯聚是不是很簡單,just so so.....呵呵



第三步:設SW1上爲VTP的服務器,其他就是客戶端模式咯,對吧!


SW1#

SW1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#vtp mode s

SW1(config)#vtp mode server  設爲服務器

Device mode already VTP SERVER.

SW1(config)#vtp do

SW1(config)#vtp domain liuye 設置一個域名,就liuye,也就是我名字。劉燁.

Changing VTP domain name from QQ to liuye  

SW1(config)#vtp pa

SW1(config)#vtp password 123456 設密碼爲123456,不設也行,這裏演示下,那我就把密碼刪掉,不要密碼。好, 刪掉....

SW1(config)#no vtp pa

SW1(config)#no vtp password 123456

Clearing device VLAN database password. 顯示已清除密碼。


SW2


SW2>en

SW2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW2(config)#vtp mode c

SW2(config)#vtp mode client 

Device mode already VTP CLIENT.

SW2(config)#vtp domain liuye

Domain name already set to liuye.


SW3


SW3>en

SW3#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW3(config)#vtp mode c

SW3(config)#vtp mode client 

Device mode already VTP CLIENT.

SW3(config)#vtp domain liuye

Domain name already set to liuye.


SW4


SW4>en

SW4#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW4(config)#vtp mode c

SW4(config)#vtp mode client 

Device mode already VTP CLIENT.

SW4(config)#vtp domain liuye

Domain name already set to liuye.


接下來在SW1上創建vlan10,vlan20,vlan30,vlan40


SW1#

SW1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#vlan 10

SW1(config-vlan)#ex

SW1(config)#vlan 20

SW1(config-vlan)#ex

SW1(config)#vlan 30

SW1(config-vlan)#ex

SW1(config)#vlan 40

SW1(config-vlan)#ex


查看下vlan創建了嗎?


SW1(config)#do show vlan


VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4

                                                Fa0/5, Fa0/6, Fa0/7, Fa0/12

                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16

                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20

                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24

                                                Gig0/1, Gig0/2

10   VLAN0010                         active    

20   VLAN0020                         active    

30   VLAN0030                         active    

40   VLAN0040                         active    

1002 fddi-default                     act/unsup 

1003 token-ring-default               act/unsup 

1004 fddinet-default                  act/unsup 

1005 trnet-default                    act/unsup 


VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2

---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

1    enet  100001     1500  -      -      -        -    -        0      0

10   enet  100010     1500  -      -      -        -    -        0      0

20   enet  100020     1500  -      -      -        -    -        0      0

30   enet  100030     1500  -      -      -        -    -        0      0

40   enet  100040     1500  -      -      -        -    -        0      0

1002 fddi  101002     1500  -      -      -        -    -        0      0   

1003 tr    101003     1500  -      -      -        -    -        0      0   

1004 fdnet 101004     1500  -      -      -        ieee -        0      0   

1005 trnet 101005     1500  -      -      -        ibm  -        0      0   


Remote SPAN VLANs

------------------------------------------------------------------------------


創建好了,查看SW2和SW3和SW4.


SW2#show vlan


VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4

                                                Fa0/5, Fa0/6, Fa0/7, Fa0/12

                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16

                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20

                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24

                                                Gig0/1, Gig0/2

10   VLAN0010                         active    

20   VLAN0020                         active    

30   VLAN0030                         active    

40   VLAN0040                         active    

1002 fddi-default                     act/unsup 

1003 token-ring-default               act/unsup 

1004 fddinet-default                  act/unsup 

1005 trnet-default                    act/unsup 


SW2學到了


SW3#show vlan


VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/5, Fa0/6, Fa0/7, Fa0/8

                                                Fa0/9, Fa0/12, Fa0/13, Fa0/14

                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18

                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22

                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2

10   VLAN0010                         active    

20   VLAN0020                         active    

30   VLAN0030                         active    

40   VLAN0040                         active    

1002 fddi-default                     act/unsup 

1003 token-ring-default               act/unsup 

1004 fddinet-default                  act/unsup 

1005 trnet-default                    act/unsup 


SW3也學到了



SW4#

SW4#show vlan


VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/5, Fa0/6, Fa0/7, Fa0/8

                                                Fa0/9, Fa0/12, Fa0/13, Fa0/14

                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18

                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22

                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2

10   VLAN0010                         active    

20   VLAN0020                         active    

30   VLAN0030                         active    

40   VLAN0040                         active    

1002 fddi-default                     act/unsup 

1003 token-ring-default               act/unsup 

1004 fddinet-default                  act/unsup 

1005 trnet-default                    act/unsup 


SW4也學到了,OK。


第四步:在SW3和SW4把相關端口劃入各個vlan


SW3


SW3#

SW3#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW3(config)#int range fa 0/1-2

SW3(config-if-range)#swi

SW3(config-if-range)#switchport ac

SW3(config-if-range)#switchport access vlan 10 

SW3(config-if-range)#ex

SW3(config)#int range fa 0/3-4

SW3(config-if-range)#swi

SW3(config-if-range)#switchport ac

SW3(config-if-range)#switchport access vlan 20


還是好習慣,查看下


SW3#show vlan


VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/5, Fa0/6, Fa0/7, Fa0/8

                                                Fa0/9, Fa0/12, Fa0/13, Fa0/14

                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18

                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22

                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2

10   VLAN0010                         active    Fa0/1, Fa0/2

20   VLAN0020                         active    Fa0/3, Fa0/4

30   VLAN0030                         active    

40   VLAN0040                         active    

1002 fddi-default                     act/unsup 

1003 token-ring-default               act/unsup 

1004 fddinet-default                  act/unsup 

1005 trnet-default                    act/unsup 


配置好了


SW4


SW4#

SW4#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW4(config)#int range fa 0/1-2

SW4(config-if-range)#swi

SW4(config-if-range)#switchport ac

SW4(config-if-range)#switchport access vlan 30

SW4(config-if-range)#ex

SW4(config)#int range fa 0/3-4

SW4(config-if-range)#swi

SW4(config-if-range)#switchport ac

SW4(config-if-range)#switchport access vlan 40


查看


SW4#

SW4#show vlan


VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/5, Fa0/6, Fa0/7, Fa0/8

                                                Fa0/9, Fa0/12, Fa0/13, Fa0/14

                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18

                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22

                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2

10   VLAN0010                         active    

20   VLAN0020                         active    

30   VLAN0030                         active    Fa0/1, Fa0/2

40   VLAN0040                         active    Fa0/3, Fa0/4

1002 fddi-default                     act/unsup 

1003 token-ring-default               act/unsup 

1004 fddinet-default                  act/unsup 

1005 trnet-default                    act/unsup 


第五步:進入SW1和SW2內的各個vlan,配上ip地址,然後在SW1上創建DHCP服務器


在SW1內的各個vlan,配上IP地址。


SW1(config)#

SW1(config)#

SW1(config)#int vlan 10

SW1(config-if)#ip ad 192.168.1.254 255.255.255.0 

SW1(config-if)#ex

SW1(config)#int vlan 20

SW1(config-if)#ip ad 192.168.2.254 255.255.255.0

SW1(config-if)#ex

SW1(config)#int vlan 30

SW1(config-if)#ip ad 192.168.3.254 255.255.255.0

SW1(config-if)#ex

SW1(config)#int vlan 40 

SW1(config-if)#ip ad 192.168.4.254 255.255.255.0

SW1(config-if)#ex


在SW2內配置各個vlan的ip地址,不能和SW1重複


SW2#

SW2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW2(config)#int vlan 10

SW2(config-if)#ip ad 192.168.1.253 255.255.255.0

SW2(config-if)#ex

SW2(config)#int vlan 20

SW2(config-if)#ip ad 192.168.2.253 255.255.255.0

SW2(config-if)#ex

SW2(config)#int vlan 30

SW2(config-if)#ip ad 192.168.3.253 255.255.255.0

SW2(config-if)#ex

SW2(config)#int vlan 40

SW2(config-if)#ip ad 192.168.4.253 255.255.255.0


在SW1上創建DHCP服務器


SW1(config)#ip dh

SW1(config)#ip dhcp pool 1 設一個名爲1的地址池

SW1(dhcp-config)#ne

SW1(dhcp-config)#network 192.168.1.0 255.255.255.0 設爲vlan10內的網段

SW1(dhcp-config)#de

SW1(dhcp-config)#default-router 192.168.1.254 默認網關

SW1(dhcp-config)#ex

SW1(config)#ip dh

SW1(config)#ip dhcp pool 2 設一個名爲2的地址池

SW1(dhcp-config)#ne

SW1(dhcp-config)#network 192.168.2.0 255.255.255.0 設爲vlan20內的網段

SW1(dhcp-config)#de

SW1(dhcp-config)#default-router 

SW1(dhcp-config)#default-router 192.168.2.254 默認網關

SW1(dhcp-config)#ex

SW1(config)#ip dh

SW1(config)#ip dhcp pool 3 設一個名爲3的地址池

SW1(dhcp-config)#ne

SW1(dhcp-config)#network 192.168.3.0 255.255.255.0 設爲vlan30內的網段

SW1(dhcp-config)#de

SW1(dhcp-config)#default-router 192.168.3.254 默認網關

SW1(dhcp-config)#ex

SW1(config)#ip dhcp pool 4 設一個名爲4的地址池

SW1(dhcp-config)#ne

SW1(dhcp-config)#network 192.168.4.0 255.255.255.0 設爲vlan40內的網段

SW1(dhcp-config)#de

SW1(dhcp-config)#default-router 192.168.4.254 默認網關

SW1(dhcp-config)#ex


當vlan10內的主機向SW1上的DHCP服務器請求ip地址時,服務器會看符合vlan10地址是什麼,它一看vlan10的ip地址是192.168.1.254,所以它就會從192.168.1.0這個網段拿出地址分配給vlan10內的主機。這是我通俗的解釋,詳細的在這上是說不完的。 vlan20,30,40也是這樣道理。


這裏提一下,還要開啓SW1和SW2的路由功能,很多人做實驗,往往都會忽略這一點。

SW1(config)#ip routing

SW2(config)#ip routing



這個時候你在用PC自動獲取ip,就能獲取到了。



第六步:多vlan生成樹(pvst),設SW1爲vlan10和vlan20的主根,爲vlan30和vlan40的備份根。

SW1#

SW1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#span

SW1(config)#spanning-tree vlan 10,20 root pri

SW1(config)#spanning-tree vlan 10,20 root primary 

SW1(config)#span

SW1(config)#spanning-tree vlan 30,40 root se

SW1(config)#spanning-tree vlan 30,40 root secondary 


查看下唄


SW1


SW1#show span

SW1#show spanning-tree vlan 10 查看基於vlan10生成樹的情況

VLAN0010

  Spanning tree enabled protocol ieee

  Root ID主根 Priority    24586 優先級 

              Address     00E0.A33E.72E4

              This bridge is the root 這個交換機就是vlan10的主根

              Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    24586  (priority 24576 sys-id-ext 10)

             Address     00E0.A33E.72E4

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p 端口轉發狀態

Po1              Desg FWD 9         128.31   Shr 匯聚組1的鏈路。端口轉發狀態


查看vlan20的


SW1#show span

SW1#show spanning-tree vlan 20

VLAN0020

  Spanning tree enabled protocol ieee

  Root ID    Priority    24596

             Address     00E0.A33E.72E4

             This bridge is the root 這個交換機就是vlan20的主根

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    24596  (priority 24576 sys-id-ext 20)

             Address     00E0.A33E.72E4

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p 端口轉發狀態

Po1              Desg FWD 9         128.31   Shr 匯聚組1的鏈路。端口轉發狀態



查看vlan30


SW1#show sp

SW1#show spanning-tree vlan 30

VLAN0030

  Spanning tree enabled protocol ieee

  Root ID    Priority    24606

             Address     00D0.D3EB.D53E 

             Cost        9

             Port        31(Port-channel 1)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    28702  (priority 28672 sys-id-ext 30)

             Address     00E0.A33E.72E4

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p 端口轉發狀態 

Po1              Root FWD 9         128.31   Shr 端口轉發狀態


查看vlan40


SW1#show sp

SW1#show spanning-tree vlan 40

VLAN0040

  Spanning tree enabled protocol ieee

  Root ID    Priority    24616 

             Address     00D0.D3EB.D53E  

             Cost        9

             Port        31(Port-channel 1)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    28712  (priority 28672 sys-id-ext 40)

             Address     00E0.A33E.72E4 

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p 端口轉發狀態

Po1              Root FWD 9         128.31   Shr 端口轉發狀態


接下來設SW2爲vlan30和vlan40的主根,爲vlan10和vlan20的備份根。


SW2#

SW2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW2(config)#sp

SW2(config)#spanning-tree vlan 30,40 root

SW2(config)#spanning-tree vlan 30,40 root p

SW2(config)#spanning-tree vlan 30,40 root primary 

SW2(config)#span

SW2(config)#spanning-tree vlan 10,20 root s

SW2(config)#spanning-tree vlan 10,20 root secondary 


再查看各個vlan生成樹的情況


vlan30的情況


SW2#show sp

SW2#show spanning-tree vlan 30  基於vlan30的生成樹

VLAN0030

  Spanning tree enabled protocol ieee

  Root ID    Priority    24606

             Address     00D0.D3EB.D53E

             This bridge is the root 這個交換機是vlan30的主根

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    24606  (priority 24576 sys-id-ext 30)

             Address     00D0.D3EB.D53E

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Po1              Desg FWD 9         128.31   Shr 匯聚組1的鏈路。端口轉發狀態

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p 端口轉發狀態


vlan40的情況


SW2#show sp

SW2#show spanning-tree vlan 40

VLAN0040

  Spanning tree enabled protocol ieee

  Root ID    Priority    24616

             Address     00D0.D3EB.D53E

             This bridge is the root 這個交換機是vlan40的主根

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    24616  (priority 24576 sys-id-ext 40)

             Address     00D0.D3EB.D53E

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Po1              Desg FWD 9         128.31   Shr 匯聚組1的鏈路。端口轉發狀態

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p  

vlan10的情況


SW2#show sp

SW2#show spanning-tree vlan 10

VLAN0010

  Spanning tree enabled protocol ieee

  Root ID    Priority    24586

             Address     00E0.A33E.72E4

             Cost        9

             Port        31(Port-channel 1)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    28682  (priority 28672 sys-id-ext 10)

             Address     00D0.D3EB.D53E

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Po1              Root FWD 9         128.31   Shr

Fa0/10           Desg FWD 19        128.10   P2p

Fa0/11           Desg FWD 19        128.11   P2p


vlan20的情況


SW2#show sp

SW2#show spanning-tree vlan 20

VLAN0020

  Spanning tree enabled protocol ieee

  Root ID    Priority    24596

             Address     00E0.A33E.72E4

             Cost        9

             Port        31(Port-channel 1)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    28692  (priority 28672 sys-id-ext 20)

             Address     00D0.D3EB.D53E

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Po1              Root FWD 9         128.31   Shr 匯聚組1的鏈路。端口轉發狀態

Fa0/10           Desg FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Desg FWD 19        128.11   P2p 端口轉發狀態


在SW3和SW4上查看各個vlan的生成樹情況


SW3

 

查看vlan10生成樹情況


SW3#show sp

SW3#show spanning-tree vlan 10

VLAN0010

  Spanning tree enabled protocol ieee

  Root ID    Priority    24586

             Address     00E0.A33E.72E4

             Cost        19

             Port        10(FastEthernet0/10)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32778  (priority 32768 sys-id-ext 10)

             Address     0001.4323.6C20

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/1            Desg FWD 19        128.1    P2p 端口轉發狀態

Fa0/2            Desg FWD 19        128.2    P2p 端口轉發狀態

Fa0/10           Root FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Altn BLK 19        128.11   P2p 端口阻塞狀態


查看vlan20生成樹情況

 

SW3#show sp

SW3#show spanning-tree vlan 20

VLAN0020

  Spanning tree enabled protocol ieee

  Root ID    Priority    24596

             Address     00E0.A33E.72E4

             Cost        19

             Port        10(FastEthernet0/10)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32788  (priority 32768 sys-id-ext 20)

             Address     0001.4323.6C20

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/3            Desg FWD 19        128.3    P2p 端口轉發狀態

Fa0/4            Desg FWD 19        128.4    P2p 端口轉發狀態

Fa0/10           Root FWD 19        128.10   P2p 端口轉發狀態

Fa0/11           Altn BLK 19        128.11   P2p 端口阻塞狀態


查看vlan30生成樹情況


SW3#show sp

SW3#show spanning-tree vlan 30

VLAN0030

  Spanning tree enabled protocol ieee

  Root ID    Priority    24606

             Address     00D0.D3EB.D53E

             Cost        19

             Port        11(FastEthernet0/11)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32798  (priority 32768 sys-id-ext 30)

             Address     0001.4323.6C20

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/10           Altn BLK 19        128.10   P2p 端口阻塞狀態

Fa0/11           Root FWD 19        128.11   P2p 端口轉發狀態


查看vlan40生成樹情況


SW3#show sp

SW3#show spanning-tree vlan 40

VLAN0040

  Spanning tree enabled protocol ieee

  Root ID    Priority    24616

             Address     00D0.D3EB.D53E

             Cost        19

             Port        11(FastEthernet0/11)

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32808  (priority 32768 sys-id-ext 40)

             Address     0001.4323.6C20

             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type

---------------- ---- --- --------- -------- --------------------------------

Fa0/10           Altn BLK 19        128.10   P2p  端口阻塞狀態

Fa0/11           Root FWD 19        128.11   P2p  端口轉發狀態


SW4就不用看了吧,自己看去。多vlan生成樹這玩意你要畫圖去研究各個關係,腦海想很容易亂,我當年也就是慢慢在紙上畫圖去比較的,慢慢就懂了,也不難,就是繞人。多理理就順了。


第七步了,曹植七步作詩。我分七步做實驗,呵呵開玩笑。

第七步:熱備份路由協議(HSRP),將SW1作爲vlan10和vlan20的主路由,爲vlan30和vlan40的備份路由。將SW2作爲vlan30和vlan40的主路由,爲vlan10和vlan20的備份路由


SW1配置

SW1>en

SW1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#int vlan 10

SW1(config-if)#st

SW1(config-if)#standby 10 ip 192.168.1.254 虛擬網關,不會和SW1上的vlan10地址衝突

SW1(config-if)#stan

SW1(config-if)#standby 10 pri 這裏的standby 10的數字10和vlan10沒關係。10是組號。

SW1(config-if)#standby 10 priority 200 設置優先級爲200,路由器默認100,優先級越高   SW1(config-if)#stan                    的就是活動路由

SW1(config-if)#standby 10 pree

SW1(config-if)#standby 10 preempt 設置搶佔

SW1(config-if)#

SW1(config-if)#ex

SW1(config)#stan

SW1(config)#st

SW1(config)#int vlan 20

SW1(config-if)#st

SW1(config-if)#standby 20 ip 192.168.2.254虛擬網關,不會和SW1上的vlan20地址衝突

SW1(config-if)#stan

SW1(config-if)#standby 20 pri

SW1(config-if)#standby 20 priority 200

SW1(config-if)#standby 20 pre

SW1(config-if)#standby 20 preempt

SW1(config-if)#ex

SW1(config)#int vlan 30

SW1(config-if)#stan

SW1(config-if)#standby 30 ip 192.168.3.254虛擬網關,不會和SW1上的vlan30地址衝突

SW1(config-if)#stan

SW1(config-if)#standby 30 pr

SW1(config-if)#standby 30 preempt

SW1(config-if)#ex

SW1(config)#int vlan 40

SW1(config-if)#stan

SW1(config-if)#standby 40 ip 192.168.4.254虛擬網關,不會和SW1上的vlan40地址衝突

SW1(config-if)#standby 40 pre

SW1(config-if)#standby 40 preempt 



查看

SW1#show standby brief 

                     P indicates configured to preempt.

                     |

Interface   Grp  Pri P State    Active活動路由  Standby備份路由 Virtual IP

Vl10        10   200 P Active   local   本地    192.168.1.253   192.168.1.254  

Vl20        20   200 P Active   local   本地    192.168.2.253   192.168.2.254  

Vl30        30   100 P Standby  192.168.3.253   local   本地    192.168.3.254  

Vl40        40   100 P Standby  192.168.4.253   local   本地    192.168.4.254 


SW2配置


SW2(config)#

SW2(config)#int vlan 10

SW2(config-if)#stan

SW2(config-if)#standby 10 ip 192.168.1.254

SW2(config-if)#sta

SW2(config-if)#standby 10 pre

SW2(config-if)#standby 10 preempt 

SW2(config-if)#ex

SW2(config)#

SW2(config)#int vlan 20

SW2(config-if)#stan

SW2(config-if)#standby 20 ip 192.168.2.254

SW2(config-if)#stan

SW2(config-if)#standby 20 pre

SW2(config-if)#standby 20 preempt 

SW2(config-if)#ex

SW2(config)#

SW2(config)#int vlan 20

SW2(config-if)#stan

SW2(config-if)#standby 20 ip 192.168.2.254

SW2(config-if)#stan

SW2(config-if)#standby 20 pre

SW2(config-if)#standby 20 preempt 

SW2(config-if)#ex

SW2(config)#

SW2(config)#

SW2(config)#int vlan 40

SW2(config-if)#stan

SW2(config-if)#standby 40 ip 192.168.4.254

SW2(config-if)#stan

SW2(config-if)#standby 40 pri

SW2(config-if)#standby 40 priority 200

SW2(config-if)#stan

SW2(config-if)#standby 40 pre

SW2(config-if)#standby 40 preempt 


查看


SW2#

SW2#show stan

SW2#show standby b

SW2#show standby brief 

                     P indicates configured to preempt.

                     |

Interface   Grp  Pri P State    Active          Standby         Virtual IP

Vl10        10   100 P Standby  192.168.1.254   local           192.168.1.254  

Vl20        20   100 P Standby  192.168.2.254   local           192.168.2.254  

Vl30        30   200 P Active   local           192.168.3.254   192.168.3.254  

Vl40        40   200 P Active   local           192.168.4.254   192.168.4.254 



和SW1比較下能看出來誰是主誰是備份。


大半夜沒事在網吧給大家純手打的,累死我了,誰能犒勞我下啊?


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章