vlan劃分及vlan間通信

一、vlan簡介
默認時交換機分割衝突域,路由器分割廣播域,vlan可以分割廣播域,而且vlan可以對硬件地址、協議、和應用程序實施限制,這樣可以保證安全性,vlan還具有靈活性和可擴張性
通常有管理員建立的valn並將端口放入每個vlan,這樣的vlan成爲靜態vlan
將主機硬件地址放入數據庫,主機接入交換機時,交換機自動爲其分配vlan,成爲動態vlan
vlan識別:
         交換機間鏈路(inter-switch link,ISL),在以太網幀上標記vlan信息,isl外部封裝方法允許這是cisco交換機專用的方法
         IEEE802.1Q,在幀中插入一個字段以標示vlan
2960系列只支持ieee802.1Q中繼協議,3560系列能支持ISL和IEEE802.1Q
vlan中繼協議VTP,子vtp域中有三種操作模式:服務器(默認模式,vtp域中至少要有一臺服務器,可以之心創建添加刪除等操作,在vtp服務器模式下,vlan配置保存在NVRAM中)、客戶機(從服務器接收信息,轉發彙總通告不做更改)、透明
vtp修剪:用來保存帶寬的一種方法;默認時vlan2--1001是可以啓用修剪的,擴展vlan1006--4096不能被修剪但vlan1從來不啓用修剪,vtp1和2 版本都支持vtp修剪
使用show   interface  trunk  命令可以看到穿越中繼鏈路的vlan
使用switchport  trunk  pruning  vlan 3-4  爲3-4vlan啓用vtp修剪
二、VLAN間的路由
實例演示如圖所示規劃:pc0 、pc3屬於vlan10,pc2、pc1屬於vlan20,ip地址如圖所示分配,route4ip爲1.1.1.2/16
1、首先規劃ip地址
2、在switch0 上Switch>en
                              Switch#config terminal
                              Switch(config)#vlan 10
                              Switch(config)#vlan 20
      創建vlan,在switch1上執行相同命令;可以用Switch#show vlan命令查看建立的valn
3、將端口分配到vlan
進入switch0
      Switch#config ter
       Enter configuration commands, one per line.  End with CNTL/Z.
      Switch(config)#inter fa0/2
      Switch(config-if)#switchport mode access   
      Switch(config-if)#switchport access valn 10
      Switch(config)#inter fa0/5
      Switch(config-if)#switchport mode access
      Switch(config-if)#switchport access valn 20
在switch1上執行相同命令將fastEthernet 0/2加入vlan20,將fastEthernet 0/5加入vlan10
使用interface  range  可以同時設置許多端口,dynamic和trunk分別用於中繼端口
4、配置中繼端口
       Switch(config)#inter fa0/3
       switchport  mode   trunk
       Switch(config)#inter fa0/4
       switchport  mode   trunk
        Switch(config)#inter fa0/1
        switchport  mode   trunk
(cisco3560交換機上有encapsulation命令,而2960則沒有
      Switch(config-if)#switchport trunk encapsulation dot1q
      Switch(config-if)#switchport mode trunk)
在中繼端口上定義允許的vlan
Switch(config-if)#switchport trunk allowed vlan ?
           WORD    VLAN IDs of the allowed VLANs when this port is in trunking mode
           add     add VLANs to the current list
           all     all VLANs
           except  all VLANs except the following
           none    no VLANs
           remove  remove VLANs from the current list
Switch(config-if)#switchport trunk allowed vlan all其後有其它選項remove可以防止特定vlan穿越中繼鏈路
變更或修改本機vlan
           Switch(config-if)#switchport trunk native vlan 40
使用Switch(config-if)# no   switchport trunk native vlan 可以將本機vlan設置回默認,交換機必須使用相同的本機vlan
配置vlan間路由,在route1的fa0/1上劃分子接口
Router>en
Router#config ter.
Router(config)#int fa0/1.1
Router(config-subif)#encapsulation dot1Q ?
  <1-1005>  IEEE 802.1Q VLAN ID
Router(config-subif)#encapsulation dot1Q 10
Router#config ter.
Router(config)#int fa0/1.2
Router(config-subif)#encapsulation dot1Q ?
  <1-1005>  IEEE 802.1Q VLAN ID
Router(config-subif)#encapsulation dot1Q 20
給子接口fa0/1.1配置ip爲192.168.0.13/24,fa0/1.2ip爲192.168.1.23/24
並把fa0/1設置成trunk口,然後s0/0/0設置ip爲1.1.1.1/16,並且需要配置時鐘頻率clock  rate
5、測試如圖所示:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章