CCNP交換篇8交換機虛擬網(wǎng)(VLANs)的設置

字號:

交換機虛擬網(wǎng)(VLANs)的設置
    交換機虛擬網(wǎng)(Virtual LANs)的設置:
    Catalyst 5000上實現(xiàn)VLAN劃分及外部VLAN路由設置
    分配VTP域(a VTP Domain)
    將Cat5000加入域
    指定中繼端口(a Trunk)
    Dynamic ISL
    分配VLAN到端口
    設置VLAN 20
    配置Router
    -------------------------------------------------------------------
    注:存在三個VLAN,在VLAN之間通過Router做路由.
    -----------------------------------------------------------------
    分配VTP域
    什么是VTP?
    VTP是VLAN Trunk Protocol的簡寫,它提供每個設備 (router 或 LAN-switch)在中繼端口(trunk ports)發(fā)送廣播. 這些廣播被發(fā)送到一個組播地址,并被所有相鄰設備接收. 這些廣播列出了發(fā)送設備的管理域,它的配置修訂號,已知的VLAN, 及已知VLAN的確定參數(shù).通過聽這些廣播,在相同管理域的所有設備都可以學習到在發(fā)送設備上配置的新的VLAN.使用這種方*,新的 VLAN只需要在管理域內(nèi)的一臺設備上建立和配置.信息會自動被相同管理域內(nèi)的其它設備學到.
    分配VTP域
    首先分配VTP域名(a VTP domain name),在相同管理域內(nèi)的交換機可以通過VTP協(xié)議互相學習VTP信息.
    Cat5001> (enable) sho vtp domain
    Domain Name Domain Index VTP Version Local Mode
    -------------------------------- ------------ ----------- -----------
    1 1 server
    Advt Interval Vlan-count Max-vlan-storage Config Revision SNMP Traps
    ------------- ---------- ---------------- --------------- -----------
    300 5 256 0 disabled
    Last Updater
    ---------------
    0.0.0.0
    Cat5001> (enable)
    Cat5001> (enable) set vtp domain cisco
    VTP domain cisco modified
    Cat5001> (enable) sho vtp domain
    Domain Name Domain Index VTP Version Local Mode
    -------------------------------- ------------ ----------- -----------
    cisco 1 1 server
    Advt Interval Vlan-count Max-vlan-storage Config Revision SNMP Traps
    ------------- ---------- ---------------- --------------- -----------
    300 5 256 0 disabled
    Last Updater
    ---------------
    0.0.0.0
    Cat5001> (enable)
    --------------------------------------------------------------------------------
    將Catalyst 5002加入域
    需要將Catalyst 5002加入名為cisco的VTP管理域, 并設為VTP client,它將接收來自VTP server 的VTP配置及更新.
    注意:Catalyst 5000系列交換機默認為VTP server.
    cat5002> (enable)
    cat5002> set vtp domain cisco mode client
    指定中繼端口(Trunk ports)
    VLAN Trunk協(xié)議(VTP)只在中繼口(ISL , LANE 和802.10)上傳輸,應在二個Catalyst5000
    交換機間定義哪個口作為中繼端口(Trunk port).
    Inter-Switch Link (ISL) 中繼用于Fast Ethernet和Gigabit Ethernet端口
    IEEE 802.10中繼用于FDDI/CDDI端口
    LAN Emulation (LANE) 中繼用于ATM 端口
    Cat5001> (enable) set trunk 1/1 on
    Port 1/1 mode set to on.
    Cat5001> (enable)
    Wed Jun 19 1996, 15:00:02 Port 1/1 has become trunk.Dynamic ISL
    有了DISL(Dynamic ISL), 你不需要修改遠端的Catalyst 5000;以下信息將顯示在遠端的Catalyst 5000.
    Wed Jun 19 1996, 15:51:59 Port 1/2 has become trunk.
    Cat5001> (enable) sho trunk
    Port Mode Status
    ------- --------- ------------
    1/1 on trunking
    1/2 auto not-trunking
    2/1-2 off not-trunking
    5/1 auto not-trunking
    5/2 auto not-trunking
    5/3 auto not-trunking
    5/4 auto not-trunking
    5/5 auto not-trunking
    5/6 auto not-trunking
    5/7 auto not-trunking
    5/8 auto not-trunking
    5/9 auto not-trunking
    5/10 auto not-trunking
    5/11 auto not-trunking
    5/12 auto not-trunking
    Port Vlans allowed
    ------- ---------------------------------------------------------------------
    1/1 1-1000
    1/2 1-1000
    2/1-2 1-1000
    5/1 1-1000
    5/2 1-1000
    5/3 1-1000
    5/4 1-1000
    5/5 1-1000
    5/6 1-1000
    5/7 1-1000
    5/8 1-1000
    5/9 1-1000
    5/10 1-1000
    5/11 1-1000
    5/12 1-1000
    Port Vlans active
    ------- ---------------------------------------------------------------------
    1/1 1
    1/2 1
    2/1-2 1
    5/1 1
    5/2 1
    5/3 1
    5/4 1
    5/5 1
    5/6 1
    5/7 1
    5/8 1
    5/9 1
    5/10 1
    5/11 1
    5/12 1
    注意: DISL在Cisco IOS軟件中不支持.
    --------------------------------------------------------------------------------
    分配VLAN到端口
    Cat5001> (enable) set vlan 2 3/2-20
    VLAN 2 modified.
    VLAN 1 modified.
    VLAN Mod/Ports
    ---- -----------------------
    2 1/1
    3/2-20
    Cat5001> (enable) set vlan 20 5/1-6
    VLAN 20 modified.
    VLAN 1 modified.
    VLAN Mod/Ports
    ---- -----------------------
    20 1/1
    5/1-6
    Configure additional information for VLAN 20.
    On the other Catalyst 5000 :
    Cat5002> (enable) set vlan 2 4/1-2,5/6-12
    VLAN 2 modified.
    VLAN 1 modified.
    VLAN Mod/Ports
    ---- -----------------------
    2 1/2
    4/1-3,4/5-23
    5/6-12
    Configure additional information for VLAN 20.
    Cat5002> (enable) set vlan 20 5/1-5
    VLAN 20 modified.
    VLAN 1 modified.
    VLAN Mod/Ports
    ---- -----------------------
    20 1/2
    5/1-5
    Configure VLAN 20 on a VTP server.
    --------------------------------------------------------------------------------
    顯示端口配置
    Cat5001> (enable) show port
    Port Name Status Vlan Level Duplex Speed Type
    ---- -------------------- ---------- ---------- ------ ------ ----- -----------
    1/1 connected 1 normal half 100 100BaseTX
    1/2 connected trunk normal half 100 100BaseTX
    2/1 connecting 1 normal half 100 FDDI
    2/2 connected 1 normal half 100 FDDI
    4/1 inactive 2 normal half 10 10BaseT
    4/2 inactive 2 normal half 10 10BaseT
    4/3 inactive 2 normal half 10 10BaseT
    4/4 notconnect 1 normal half 10 10BaseT
    4/5 inactive 2 normal half 10 10BaseT
    4/6
    此時, VLAN 2 和VLAN 20 還未激活.所以在VLAN 2和VLAN 20的端口是inactive狀態(tài).
    --------------------------------------------------------------------------------
    設置VLAN 20
    如果在網(wǎng)絡里有VTP server和VTP clent,請在VTP server上設置VLAN 20
    Cat5001> (enable) set vlan 20
    VLAN 20 modified
    這將激活在所有管理域cisco內(nèi)的VLAN 20
    Cat5001> (enable) sho vlan 20
    VLAN Name Status Mod/Ports
    ---- -------------------------------- --------- ----------------------------
    20 VLAN0020 active 1/1
    5/1-6
    VLAN Type SAID MTU Parent RingNo BridgeNo Stp Trans1 Trans2
    ---- ----- ---------- ----- ------ ------ -------- ---- ------ ------
    20 enet 100020 1500 - - - - 0 0
    --------------------------------------------------------------------------------
    配置Router
    conf t
    interface FastEthernet0/0.1 <-- you need to create a sub-interface by vlan.
    encapsulation isl 20 <-- 20 is the vlan number.
    ip address 1.1.1.1 255.255.255.0
    interface FastEthernet0/0.2
    encapsulation isl 2
    ip address 2.2.2.1 255.255.255.0
    interface FastEthernet0/0.3
    encapsulation isl 1
    ip address 172.16.80.1 255.255.255.0
    Router eigrp 666
    network 1.0.0.0
    network 2.0.0.0
    network 172.16.80.0
    end
    writ mem
    DHCP SERVER遷移到6509交換機的MSFC
    一位客戶想把DHCP SERVER遷移到6509交換機的MSFC上,要求還挺復雜:
    1.同時為多個VLAN的客戶機分配地址
    2.VLAN內(nèi)有部分地址采用手工分配的方式
    3.為客戶指定網(wǎng)關(guān)、Wins服務器等
    4.VLAN 2的地址租用有效期限為1天,其它為3天
    5.按MAC地址為特定用戶分配指定的IP地址
    最終配置如下:
    ip dhcp excluded-address 10.1.1.1 10.1.1.19 //不用于動態(tài)地址分配的地址
    ip dhcp excluded-address 10.1.1.240 10.1.1.254
    ip dhcp excluded-address 10.1.2.1 10.1.2.19
    !
    ip dhcp pool global //global是pool name, 由用戶指定
    network 10.1.0.0 255.255.0.0 //動態(tài)分配的地址段
    domain-name client.com //為客戶機配置域后綴
    dns-server 10.1.1.1 10.1.1.2 //為客戶機配置dns服務器
    netbios-name-server 10.1.1.5 10.1.1.6 //為客戶機配置wins服務器
    netbios-node-type h-node //為客戶機配置節(jié)點模式(影響名稱解釋的順利,如h-node=先通過wins服務器解釋...)
    lease 3 //地址租用期限: 3天
    ip dhcp pool vlan1
    network 10.1.1.0 255.255.255.0 //本pool是global的子pool, 將從global pool繼承domain-name等option
    default-router 10.1.1.100 10.1.1.101 //為客戶機配置默認網(wǎng)關(guān)
    !
    ip dhcp pool vlan2 //為另一VLAN配置的pool
    network 10.1.2.0 255.255.255.0
    default-router 10.1.2.100 10.1.2.101
    lease 1
    !
    ip dhcp pool vlan1_john //總是為MAC地址為...的機器分配...地址
    host 10.1.1.21 255.255.255.0
    client-identifier 010050.bade.6384 //client-identifier=01加上客戶機網(wǎng)卡地址
    !
    ip dhcp pool vlan1_tom
    host 10.1.1.50 255.255.255.0
    client-identifier 010010.3ab1.eac8
    相關(guān)的DHCP調(diào)試命令:
    no service dhcp //停止DHCP服務[默認為啟用DHCP服務]
    sh ip dhcp binding //顯示地址分配情況
    show ip dhcp conflict //顯示地址沖突情況
    debug ip dhcp server {events | packets | linkage} //觀察DHCP服務器工作情況
    如果DHCP客戶機分配不到IP地址,常見的原因有兩個。第一種情況是沒有把連接客戶機的端口設置為Portfast方式。MS客戶機開機后檢查網(wǎng)卡連接正常,Link是UP的,就開始發(fā)送DHCPDISCOVER請求,而此時交換機端口正在經(jīng)歷生成樹計算,一般需要30-50秒才能進入轉(zhuǎn)發(fā)狀態(tài)。MS客戶機沒有收到DHCP SERVER的響應就會給網(wǎng)卡設置一個169.169.X.X的IP地址。解決的方法是把交換機端口設置為Portfast方式:CatOS(4000/5000/6000): set spantree portfast mod_num/port_num enable; IOS(2900/3500): interface ... ; spanning-tree portfast。
    另外一種情況是DHCP服務器和DHCP工作站不在同一個VLAN,這時候通常通過設置ip helper-address來解決:
    interface vlan1
    ip address 10.1.1.254 255.255.255.0 //假設DHCP服務器地址為10.1.1.8
    interface Vlan2
    ip address 10.1.2.254 255.255.255.0
    ip helper-address 10.1.1.8 //假設這是DHCP客戶機所在的VLAN
    第三層交換建設企業(yè)VLAN
    虛擬局域網(wǎng)(VLAN)的出現(xiàn)打破了傳統(tǒng)網(wǎng)絡的許多固有觀念,使網(wǎng)絡結(jié)構(gòu)變得靈活、方便、隨心所欲。VLAN就是不考慮用戶的物理位置而根據(jù)功能、應用等因素將用戶邏輯上劃分為一個個功能相對獨立的工作組,每個用戶主機都連接在一個支持VLAN的交換機端口上并屬于一個VLAN。同一個VLAN中的成員都共享廣播,而不同VLAN之間廣播信息是相互隔離的。這樣,將整個網(wǎng)絡分割成多個不同的廣播域。
    傳統(tǒng)的路由器在網(wǎng)絡中有路由轉(zhuǎn)發(fā)、防火墻、隔離廣播等作用,而在一個劃分了VLAN以后的網(wǎng)絡中,邏輯上劃分的不同網(wǎng)段之間通信仍然要通過路由器轉(zhuǎn)發(fā)。由于在局域網(wǎng)上,不同VLAN之間的通信數(shù)據(jù)量是很大的,這樣,如果路由器要對每一個數(shù)據(jù)包都路由一次,隨著網(wǎng)絡上數(shù)據(jù)量的不斷增大,路由器將不堪重負,路由器將成為整個網(wǎng)絡的瓶頸。
    在這種情況下,出現(xiàn)了第三層交換技術(shù),通俗地講,就是將路由技術(shù)與交換技術(shù)合二為一的技術(shù)。路由器在對第一個數(shù)據(jù)流進行路由后,將會產(chǎn)生一個MAC地址與IP地址的映射表,當同樣的數(shù)據(jù)流再次通過時,將根據(jù)此表直接從二層通過而不是再次路由,從而消除了路由器進行路由選擇而造成網(wǎng)絡的延遲,提高了數(shù)據(jù)包轉(zhuǎn)發(fā)的效率,消除了路由器可能產(chǎn)生的網(wǎng)絡瓶頸問題。
    配置VLAN
    (1) VLAN的工作模式:
    靜態(tài)VLAN:管理員針對交換機端口指定VLAN。
    動態(tài)VLAN:通過設置VMPS(VLAN Membership Policy Server),包含了一個MAC地址與VLAN號的映射表,當數(shù)據(jù)幀到達交換機后,交換機會查詢VMPS獲得相應MAC地址的VLAN ID。
    (2) ISL標簽:ISL(Inter-Switch Link)是一個在交換機之間、交換機與路由器之間及交換機與服務器之間傳遞多個VLAN信息及VLAN數(shù)據(jù)流的協(xié)議,通過在交換機直接相連的端口配置ISL封裝,即可跨越交換機進行整個網(wǎng)絡的VLAN分配和進行配置。
    VLAN封裝的國際標準為IEEE 802.1Q。
    (3) VTP(VLAN Trunking Protocol):它是一個在交換機之間同步及傳遞VLAN配置信息的協(xié)議。一個VTP Server上的配置將會傳遞給網(wǎng)絡中的所有交換機,VTP通過減少手工配置而支持較大規(guī)模的網(wǎng)絡。VTP有三種模式:
    Server模式:允許創(chuàng)建、修改、刪除VLAN及其他一些對整個VTP域的配置參數(shù),同步本VTP域中其他交換機傳遞來的最新的VLAN信息。
    Client模式:在Client模式下,一臺交換機不能創(chuàng)建、刪除、修改VLAN配置,也不能在NVRAM中存儲VLAN配置,但可以同步由本VTP域中其他交換機傳遞來的VLAN信息。
    Transparent模式:可以進行創(chuàng)建、修改、刪除,也可以傳遞本VTP域中其他交換機送來的VTP廣播信息,但并不參與本VTP域的同步和分配,也不將自己的VLAN配置傳遞給本VTP域中的其他交換機,它的VLAN配置只影響到它自己。
    交換機在默認情況下為Server模式。
    (4) 創(chuàng)建VLAN,默認情況下交換機只有VLAN 1,可以通過命令增加所需的VLAN。
    (5) 將VLAN指定給交換機的各個端口。默認情況下交換機所有端口均屬于VLAN 1,可以通過全局命令修改交換機各端口的VLAN ID,但交換機每個端口只能屬于一個VLAN。
    配置三層交換
    配置MLSP協(xié)議,使RP與SE之間可以交換信息。
    配置管理端口,MLSP通過這個端口收發(fā)RP與SE之間的通信。
    針對不同的VLAN分配不同的VLAN網(wǎng)關(guān)地址。
    啟動路由器的路由功能。
    根據(jù)需要,可以定義VLAN虛網(wǎng)間的訪問策略,可通過定義訪問列表來實現(xiàn)。