利用路由器實現不同VLAN間的訪問

利用路由器實現不同VLAN間的訪問

2011-08-03 16:51:07

原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任。http://287416363.blog.51cto.com/2189452/630221
【實驗名稱】
VLAN/802.1Q-VLAN間的通信
【實驗目的】
通過路由器實現VLAN間互相通信
【實驗功能】
使在同一VLAN裏的計算機系統能跨路由器進行相互通信,而在不同VLAN裏的計算機系統也能進行相互通信
【實驗設備】
路由器(1臺)、交換機(1臺)、PC(2臺) 直連線(3條)
【實驗拓撲】
 
 
 
(因爲前面已經配置了一個《利用三層交換機實現不同VLAN的相互通信》 ,所以這裏用一個簡單的TP來說明! 配置都一樣 在這裏主要闡述路由器的配置)
【實驗步驟】
交換機
Switch>enable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/2
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/3
Switch(config-if)#switchport access vlan 3
Switch(config)#interface fastEthernet 0/24
 Switch(config-if)#switchport mode trunk
(配置到這裏你會發現 二層交換機 配來配去 就那麼幾步! 創建VLAN 把端口劃分到VLAN 然後設置TRUNK口)
是不是覺得 二層太小兒科!  呵呵   是這樣的  ! 我們要在 #戰略上藐視敵人,戰術上重視敵人#! 雖然簡單,也不能大意!
接下來本節重點
路由器:
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0                                  (與二層TRUNK口連接的物理接口只需要打開)
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastEthernet 0/0.2                              (進入物理接口的子接口:(.2) 可以想象成物理接口 一個物理接口可以有 幾十億個子接口 子接口可以隨意設置)
Router(config-subif)#encapsulation dot1Q 2    (配置子接口的封裝協議時dot1Q  後面2要注意!此時不可隨意設置 這裏的2時VLAN編號 要與交換機相互對應)
Router(config-subif)#ip address 192.168.2.254 255.255.255.0     (配置IP地址 即VLAN2 網關)
Router(config-subif)#exit
Router(config)#interface fastEthernet 0/0.3                    (同樣給VLAN3)
Router(config-subif)#encapsulation dot1Q 3
Router(config-subif)#ip address 192.168.3.254 255.255.255.0
此時給VLAN2 PC配置 IP 192.168.2.1 255.255.255.0 網關 192.168.2.254
VLAN3 PC配置 IP 192.168.3.1 255.255.255.0 網關 192.168.3.254
發現
PC>ping 192.168.3.1
Pinging 192.168.3.1 with 32 bytes of data:
Reply from 192.168.3.1: bytes=32 time=96ms TTL=127
Reply from 192.168.3.1: bytes=32 time=125ms TTL=127
Reply from 192.168.3.1: bytes=32 time=125ms TTL=127
Reply from 192.168.3.1: bytes=32 time=125ms TTL=127
Ping statistics for 192.168.3.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 96ms, Maximum = 125ms, Average = 117ms
不同VLAN通過路由器實現了通信!!

本文出自 “一切皆有口可能!” 博客,請務必保留此出處http://287416363.blog.51cto.com/2189452/630221

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