vlan,trunk,DHCP,以太網通道


Vlan的划分

1.1 問題

VLAN(虛擬局域網)是對連接到的第二層交換機端口的網絡用戶的邏輯分段,不受網絡用戶的物理位置限制而根據用戶需求進行網絡分段。 一個VLAN可以在一個交換機或者跨交換機實現。VLAN可以根據網絡用戶的位置、作用、部門或者根據網絡用戶所使用的應用程序和協議來進行分組。基於交 換機的虛擬局域網能夠為局域網解決沖突域、廣播域、帶寬問題。

  • 按企業部門規划vlan

1.2 方案

在交換機上創建vlan2、vlan3,參照如下網絡拓撲如圖-1所示:

圖-1

1.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:客戶端與交換機相連

1)為了使同vlan在交換機上可以通信,需要給同vlan客戶端配置同網段IP地址,如圖-2、圖-3所示

圖-2

圖-3

分別配置為192.168.1.1、192.169.1.2;192.168.2.1、192.168.2.2;192.168.3.1、192.168.3.2;

2)在交換機上創建vlan2 和vlan3並將指定的接口划分到相對應的vlan下

  1. Switch >enable
  2. Switch#configure terminal
  3. Switch(config)#vlan 2
  4. Switch(config-vlan)#exit
  5. Switch(config)#vlan 3
  6. Switch(config-vlan)#exit
  7. Switch(config)#interface fastEthernet 0/3
  8. Switch(config-if)#switchport access vlan 2
  9. Switch(config-if)#exit
  10. Switch(config)#interface fastEthernet 0/4
  11. Switch(config-if)#switchport access vlan 2
  12. Switch(config-if)#exit
  13. Switch(config)#interface fastEthernet 0/5
  14. Switch(config-if)#switchport access vlan 3
  15. Switch(config-if)#exit
  16. Switch(config)#interface fastEthernet 0/6
  17. Switch(config-if)#switchport access vlan 3

3)在交換機上查看vlan信息,可以看到創建的vlan以及vlan下的接口

  1. Switch>enable
  2. Switch#show vlan
  3. VLAN Name Status Ports
  4. ---- -------------------------------- --------- -------------------------------
  5. 1 default active Fa0/1, Fa0/2, Fa0/7, Fa0/8
  6. Fa0/9, Fa0/10, Fa0/11, Fa0/12
  7. Fa0/13, Fa0/14, Fa0/15, Fa0/16
  8. Fa0/17, Fa0/18, Fa0/19, Fa0/20
  9. Fa0/21, Fa0/22, Fa0/23, Fa0/24
  10. 2 VLAN0002 active Fa0/3, Fa0/4
  11. 3 VLAN0003 active Fa0/5, Fa0/6
  12. 1002 fddi-default act/unsup
  13. 1003 token-ring-default act/unsup
  14. 1004 fddinet-default act/unsup
  15. 1005 trnet-default act/unsup
  16. VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
  17. ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
  18. 1 enet 100001 1500 - - - - - 0 0
  19. 2 enet 100002 1500 - - - - - 0 0
  20. 3 enet 100003 1500 - - - - - 0 0
  21. 1002 fddi 101002 1500 - - - - - 0 0
  22. 1003 tr 101003 1500 - - - - - 0 0
  23. 1004 fdnet 101004 1500 - - - ieee - 0 0
  24. 1005 trnet 101005 1500 - - - ibm - 0 0
  25. Remote SPAN VLANs
  26. ------------------------------------------------------------------------------
  27. Primary Secondary Type Ports
  28. ------- --------- ----------------- ------------------------------------------

4)在客戶端測試網絡的連通性

在192.168.1.0/24的客戶機上測試1.0網段的連通性

  1. PC1>ping 192.168.1.2
  2. Pinging 192.168.1.2 with 32 bytes of data:
  3. Reply from 192.168.1.2: bytes=32 time=11ms TTL=128
  4. Reply from 192.168.1.2: bytes=32 time=1ms TTL=128
  5. Reply from 192.168.1.2: bytes=32 time=1ms TTL=128
  6. Reply from 192.168.1.2: bytes=32 time=4ms TTL=128
  7. Ping statistics for 192.168.1.2:
  8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  9. Approximate round trip times in milli-seconds:
  10. Minimum = 1ms, Maximum = 11ms, Average = 4ms

5)在192.168.2.0/24的客戶機上測試2.0網段的連通性

  1. PC>ping 192.168.2.2
  2. Pinging 192.168.2.2 with 32 bytes of data:
  3. Reply from 192.168.2.2: bytes=32 time=1ms TTL=128
  4. Reply from 192.168.2.2: bytes=32 time=0ms TTL=128
  5. Reply from 192.168.2.2: bytes=32 time=0ms TTL=128
  6. Reply from 192.168.2.2: bytes=32 time=0ms TTL=128
  7. Ping statistics for 192.168.2.2:
  8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  9. Approximate round trip times in milli-seconds:
  10. Minimum = 0ms, Maximum = 1ms, Average = 0ms

6)在192.168.3.0/24的客戶機上測試3.0網段的連通性

  1. PC>ping 192.168.3.2
  2. Pinging 192.168.3.2 with 32 bytes of data:
  3. Reply from 192.168.3.2: bytes=32 time=1ms TTL=128
  4. Reply from 192.168.3.2: bytes=32 time=0ms TTL=128
  5. Reply from 192.168.3.2: bytes=32 time=0ms TTL=128
  6. Reply from 192.168.3.2: bytes=32 time=1ms TTL=128
  7. Ping statistics for 192.168.3.2:
  8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  9. Approximate round trip times in milli-seconds:
  10. Minimum = 0ms, Maximum = 1ms, Average = 0ms

2 案例2:配置trunk中繼鏈路

2.1 問題

在兩台交換機上分別創建vlan2、vlan3,參照如下網絡拓撲圖-4將端口加入到指定的vlan並配置IP址,實現跨交換機的同vlan主機的通信。

圖-4

2.2 方案

分別在sw1和sw2上創建vlan2和vlan3並把相應的接口划分到對應的vlan並為客戶端配置IP地址,IP地址具有唯一性所以同一局域網絡中不能存在相同的IP,另所有的接口默認為vlan1,所以不配置trunk中繼鏈路vlan1也是可以跨交換機通信的。

2.3 步驟

實現此案例需要按照如下步驟進行

步驟一:為客戶端配置IP,分別為交換機sw1和sw2創建vlan並把相應的接口划到相對應的vlan下

1)參照圖-4為客戶端分別配置相對應網段的IP

2)為交換機創建vlan2、vlan3 並把相應的接口划到vlan下

  1. Switch >enable
  2. Switch#configure terminal
  3. Switch(config)#hostname SW1
  4. SW1 (config)#Switch(config-vlan)#exit
  5. SW1 (config)#vlan 3
  6. SW1 (config-vlan)#exit
  7. SW1 (config)#interface fastEthernet 0/3
  8. SW1 (config-if)#switchport access vlan 2
  9. SW1 (config-if)#exit
  10. SW1 (config)#interface fastEthernet 0/4
  11. SW1 (config-if)#switchport access vlan 2
  12. SW1 (config-if)#exit
  13. SW1 (config)#interface fastEthernet 0/5
  14. SW1 (config-if)#switchport access vlan 3
  15. SW1 (config-if)#exit
  16. SW1 (config)#interface fastEthernet 0/6
  17. SW1 (config-if)#switchport access vlan 3
  18. Switch >enable
  19. Switch#configure terminal
  20. Enter configuration commands, one per line. End with CNTL/Z.
  21. Switch(config)#hostname SW2
  22. SW2 (config)#Switch(config-vlan)#exit
  23. SW2 (config)#vlan 3
  24. SW2 (config-vlan)#exit
  25. SW2 (config)#interface fastEthernet 0/3
  26. SW2(config-if)#switchport access vlan 2
  27. SW2 (config-if)#exit
  28. SW2 (config)#interface fastEthernet 0/4
  29. SW2 (config-if)#switchport access vlan 2
  30. SW2 (config-if)#exit
  31. SW2 (config)#interface fastEthernet 0/5
  32. SW2 (config-if)#switchport access vlan 3
  33. SW2 (config-if)#exit
  34. SW2 (config)#interface fastEthernet 0/6
  35. SW2 (config-if)#switchport access vlan 3

3)分別查看SW1和SW2交換機上的vlan信息

  1. SW1#show vlan
  2. VLAN Name Status Ports
  3. ---- -------------------------------- --------- -------------------------------
  4. 1 default active Fa0/1, Fa0/2, Fa0/8, Fa0/9
  5. Fa0/10, Fa0/11, Fa0/12, Fa0/13
  6. Fa0/14, Fa0/15, Fa0/16, Fa0/17
  7. Fa0/18, Fa0/19, Fa0/20, Fa0/21
  8. Fa0/22, Fa0/23, Fa0/24
  9. 2 VLAN0002 active Fa0/3, Fa0/4
  10. 3 VLAN0003 active Fa0/5, Fa0/6
  11. 1002 fddi-default act/unsup
  12. 1003 token-ring-default act/unsup
  13. 1004 fddinet-default act/unsup
  14. 1005 trnet-default act/unsup
  15. VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
  16. ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
  17. 1 enet 100001 1500 - - - - - 0 0
  18. 2 enet 100002 1500 - - - - - 0 0
  19. 3 enet 100003 1500 - - - - - 0 0
  20. 1002 fddi 101002 1500 - - - - - 0 0
  21. 1003 tr 101003 1500 - - - - - 0 0
  22. 1004 fdnet 101004 1500 - - - ieee - 0 0
  23. 1005 trnet 101005 1500 - - - ibm - 0 0
  24. Remote SPAN VLANs
  25. ------------------------------------------------------------------------------
  26. Primary Secondary Type Ports
  27. ------- --------- ----------------- ------------------------------------------
  28. SW1#
  29. SW2#show vlan
  30. VLAN Name Status Ports
  31. ---- -------------------------------- --------- -------------------------------
  32. 1 default active Fa0/1, Fa0/2, Fa0/8, Fa0/9
  33. Fa0/10, Fa0/11, Fa0/12, Fa0/13
  34. Fa0/14, Fa0/15, Fa0/16, Fa0/17
  35. Fa0/18, Fa0/19, Fa0/20, Fa0/21
  36. Fa0/22, Fa0/23, Fa0/24
  37. 2 VLAN0002 active Fa0/3, Fa0/4
  38. 3 VLAN0003 active Fa0/5, Fa0/6
  39. 1002 fddi-default act/unsup
  40. 1003 token-ring-default act/unsup
  41. 1004 fddinet-default act/unsup
  42. 1005 trnet-default act/unsup
  43. VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
  44. ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
  45. 1 enet 100001 1500 - - - - - 0 0
  46. 2 enet 100002 1500 - - - - - 0 0
  47. 3 enet 100003 1500 - - - - - 0 0
  48. 1002 fddi 101002 1500 - - - - - 0 0
  49. 1003 tr 101003 1500 - - - - - 0 0
  50. 1004 fdnet 101004 1500 - - - ieee - 0 0
  51. 1005 trnet 101005 1500 - - - ibm - 0 0
  52. Remote SPAN VLANs
  53. ------------------------------------------------------------------------------
  54. Primary Secondary Type Ports
  55. ------- --------- ----------------- ------------------------------------------
  56. SW2#

步驟二:為交換機配置trunk中繼鏈接路

1)分別進入兩台交換機相連接的f0/7接口配置trunk中繼鏈路

  1. SW1>enable
  2. SW1#configure terminal
  3. SW1(config)#interface fastEthernet 0/7
  4. SW1(config-if)#switchport mode trunk
  5. SW2#enable
  6. SW2#configure terminal
  7. SW2(config)#interface fastEthernet 0/7
  8. SW2(config-if)#switchport mode trunk
  9. SW2(config-if)#

2)測試2.0網段和3.0網段跨交換機通信

  1. PC>ping 192.168.2.3
  2. Pinging 192.168.2.3 with 32 bytes of data:
  3. Reply from 192.168.2.3: bytes=32 time=1ms TTL=128
  4. Reply from 192.168.2.3: bytes=32 time=0ms TTL=128
  5. Reply from 192.168.2.3: bytes=32 time=0ms TTL=128
  6. Reply from 192.168.2.3: bytes=32 time=0ms TTL=128
  7. Ping statistics for 192.168.2.3:
  8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  9. Approximate round trip times in milli-seconds:
  10. Minimum = 0ms, Maximum = 1ms, Average = 0ms
  11. PC>ping 192.168.3.3
  12. Pinging 192.168.3.3 with 32 bytes of data:
  13. Reply from 192.168.3.3: bytes=32 time=1ms TTL=128
  14. Reply from 192.168.3.3: bytes=32 time=0ms TTL=128
  15. Reply from 192.168.3.3: bytes=32 time=0ms TTL=128
  16. Reply from 192.168.3.3: bytes=32 time=0ms TTL=128
  17. Ping statistics for 192.168.3.3:
  18. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  19. Approximate round trip times in milli-seconds:
  20. Minimum = 0ms, Maximum = 1ms, Average = 0ms

3 案例3:以太通道配置

3.1 問題

企業需要增加帶寬和網絡可用性,以太通道可以同時滿足這兩個條件,而又無需購買新設備。

3.2 方案

在某些環境下,為了在現有條件下增加帶寬而不增加額外的設備,以太通道是可用技術之一。以太通道為交換機提供了端口捆綁的技術,允許兩個交換機之間通過兩個或多個端口並行連接,同時傳輸數據,以提供更高的帶寬。

企業網絡模擬拓撲環境如圖-5所示:

圖-5

3.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:在交換機A上分別配置以太通道

太通道的配置模式與Trunk類似,也有開啟、企望等。同樣的,在生產環境下都是強制設置以太通道處於on的狀態,而不是讓它們自動協商。

  1. sw1(config)# interface range fastEthernet 0/7 – 9
  2. Switch(config-if-range)#switchport mode trunk
  3. sw1(config-if-range)#channel-group 1 mode on
  4. sw1(config-if-range)#

步驟二:在交換機B上分別配置以太通道

  1. sw2(config)# interface range fastEthernet 0/7 – 9
  2. Switch(config-if-range)#switchport mode trunk
  3. sw2(config-if-range)#channel-group 1 mode on
  4. sw2(config-if-range)#

步驟三:在交換機A上查看以太通通道配置

  1. sw1# show etherchannel 1 summary
  2. Flags: D - down P - in port-channel
  3. I - stand-alone s - suspended
  4. H - Hot-standby (LACP only)
  5. R - Layer3 S - Layer2
  6. U - in use f - failed to allocate aggregator
  7. u - unsuitable for bundling
  8. w - waiting to be aggregated
  9. d - default port
  10. Number of channel-groups in use: 1
  11. Number of aggregators: 1
  12. Group Port-channel Protocol Ports
  13. ------+-------------+-----------+---------------------------------
  14. 1 Po1(SU) - Fa0/7(P) Fa0/8(P) Fa0/9(P)

根據輸出最后一行小括號中的提示,可以獲知以太通道是二層的(S)、正在被使用的(U),端口Fa0/7、Fa0/8和Fa09在以太通道中(P)。

步驟四:創建以太通道后,系統會增加一個名稱為Port-channel 1的端口,可以通過show running-config命令查看到其信息

  1. sw2#show running-config
  2. Building configuration...
  3. Current configuration : 1308 bytes
  4. !
  5. version 12.2
  6. no service timestamps log datetime msec
  7. no service timestamps debug datetime msec
  8. no service password-encryption
  9. !
  10. hostname tarena-sw2
  11. !
  12. !
  13. .. ..
  14. interface Port-channel 1 //以太通道信息
  15. switchport mode trunk
  16. !
  17. .. ..

4 案例4:DHCP服務配置

4.1 問題

大型企業網絡客戶機數量較多,客記機IP地址配置如果都為靜態配置存在如下問題:

  • 增加網絡管理員工作量
  • 靜態手動配置容易輸入錯誤
  • 靜態手動配置容易沖突

4.2 方案

在路由器上配置DHCP服務為客戶端自動分配IP地址如圖-6所示:

圖-6

    • VLAN 1:192.168.1.0/24
    • 網關192.168.1.254
    • 首選DNS為202.106.0.20
    • 預留IP地址打印服務器:192.168.1.1
    • 預留IP地址文件服務器:192.168.1.100

 

4.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:路由器R1配置DHCP服務

1)配置路由器接口IP

  1. R1(config)#interface fastEthernet 0/0
  2. R1(config-if)#ip address 192.168.1.254 255.255.255.0
  3. R1(config-if)#no shutdown

2)DHCP服務配置

  1. R1(config)#ip dhcp pool vlan11)
  2. R1(dhcp-config)#network 192.168.1.0 255.255.255.0
  3. R1(dhcp-config)#default-router 192.168.1.254
  4. R1(dhcp-config)#dns-server 202.106.0.20
  5. R1(config)#ip dhcp excluded-address 192.168.1.1
  6. R1(config)#ip dhcp excluded-address 192.168.1.100

3)設置主機A的IP配置為自動獲取如圖-7所示:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM