這篇博客完全是爲了水實驗,233333.。
實驗一:實驗路由之間Vlan
注意點一:PC機需要設置IP 還有下面的子網掩碼
然後在路由器設置如下(括號裏面的是全名,可以輸出簡寫):
enable :進入特權模式
conf(configure) term(terminal) ://進入全局模式
inte(interface) f0/1 //進入端口1(這裏看你連接路由器的哪個端口)
switch(switchport) access vlan 10 //把現在的端口加入到vlan 10 沒有就hi自動生成
exit //返回上一層
其他的類似即可,然後PING 不同Vlan之間的主機 不能Ping通,相同的主機才能PING通。
實驗二:跨交換機實現Vlan
不同交換機之間的相同Vlan可以相互Ping通。
給所有PC設置IP和子網掩碼
(我是實驗PC1 設置PC3設置爲Vlan 10 ,PC2和PC4設置Vlan20,兩個交換機都是24端口作爲連接)
進入其中一臺交換機(如1,PC1和PC2連接在這裏):
首先把PC1和PC2設置Vlan10 和20 和實驗一一樣就跳過了。
在全局模式下我們設置24端口
inte(interface) f0/24 //進入24端口
switch(switchport) mode trunk //把24端口設置爲Tag VLAN模式
然後 交換機二一樣,測試PING不同的Vlan和相同的Vlan 看能否Ping通
實驗三:三層路由器間交換
設置PCPI如下(掩碼都是255.255.255.0):
PC1: 192.168.10.1(VLAN10)
PC2:192.168.20.2(VLAN20)
PC3:192.168.10.3(VLAN10)
PC4: 192.168.20.4(VLAN)
24端口爲路由連接窗口
首先設置Vlan和上面一樣
然後進入24端口設置trunk(記得先inte f0/24 //進入端口再設置)
如何出現下面錯誤:Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk”
在24端口下輸入: switch trunk enca dot1q (switchport trunk encapsulation dot1q )//注意是1 不是L,123456的1
然後再輸出:switch mode trunk
兩個交換機都要設置trunk
然後進入Vlan設置地址
在全局模式下(conf term下)
ip rounting //啓用IP路由功能
inte vlan10 //進入vlan10
ip address 192.168.10.254 255.255.255.0 // 配置虛擬接口VLAN10的地址爲192.168.10.254 後面是子網掩碼
exit
inte vlan20 //進入vlan20
ip address 192.168.20.254 255.255.255.0 // 配置虛擬接口VLAN20的地址爲192.168.20.254 後面是子網掩碼
exit
然後互相PING測試。