兩層交換機上劃分VLAN借三層交換機路由功能實現跨網段訪問(Cisco Packer Tracer 模擬器)
阿新 • • 發佈:2019-01-09
忙活了一下午 , 終於成功了 不容易啊!
還是 發一下 博文吧,
【簡單拓撲圖】:
【註釋】
這裡 劃分了 兩個vlan 3 和 4 vlan3 分佈在交換機1 和 2 中
【注意】
ip 與閘道器的網段保持一致!!!!不要忘記設定主機閘道器 以及埠與命令保持一致!!! this very important!!
【命令】:
交換機1: 配置 VALN 3
Switch#en Switch#conf Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 3 Switch(config-vlan)#exit Switch(config)#int fa0/1 // fa0/1 與fa0/2 埠接在 vlan3 上 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3 Switch(config-if)#exit Switch(config)#int fa0/2 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3 Switch(config)#int fa0/24 // fa0/4路線設定成trunk模式 Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config-if)# %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up Switch(config-if)#end Switch# %SYS-5-CONFIG_I: Configured from console by console
交換機2: 含兩個vlan 3 和 4
Switch#en Switch#conf Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 3 Switch(config-vlan)#vlan 4 Switch(config-vlan)#exit Switch(config)#int fa0/1 // fa0/1 與fa0/2 埠接在 vlan4 上 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 4 Switch(config-if)#exit Switch(config)#int fa0/2 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 4 Switch(config)#int fa0/3 // fa0/3 埠接在 vlan3 上 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3 Switch(config-if)#exit Switch(config)#int fa0/24 // fa0/4路線設定成trunk模式 Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config)#end Switch# %SYS-5-CONFIG_I: Configured from console by console
三層交換機: 配置vlan 3和 4 並設定閘道器設定為routing模式
Switch>en Switch#conf Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 3 // 創造 VLAN 3 和 4 Switch(config-vlan)#vlan 4 Switch(config-vlan)#exit Switch(config)#int vlan 3 // VLAN 3 設定閘道器地址 Switch(config-if)# %LINK-5-CHANGED: Interface Vlan3, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up Switch(config-if)#ip address 192.168.3.69 255.255.255.0 Switch(config-if)#no shut Switch(config-if)#exit Switch(config)#int vlan 4 // VLAN 4設定閘道器地址 Switch(config-if)# %LINK-5-CHANGED: Interface Vlan4, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan4, changed state to up Switch(config-if)#ip address 192.168.4.69 255.255.255.0 Switch(config-if)#no shut Switch(config-if)#int fa0/1 //fa0/1 和fa0/2 設定為trunk 模式 Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config-if)# %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up Switch(config-if)#exit Switch(config)#int fa0/2 //fa0/1 和fa0/2 設定為trunk 模式 Switch(config-if)#switchport mode access Switch(config-if)#switchport mode trunk Switch(config-if)# %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up Switch(config-if)#ip routing // 開啟 路由功能!!!!!!!!!!!!! very important!! Switch(config)#end Switch# %SYS-5-CONFIG_I: Configured from console by console
【測試】
PC –1 ping -----------à others
ping 192.168.3.2 同一換機 同一vlan
ping 通
ping 192.168.4.3 不同交換機 不同vlan
ping 通 第一次 存在丟包原因:ping第一個資料是ARP廣播包,建立MAC地址和IP地址對應表,因為一開始是不知道對方的MAC地址所以丟包
第二次就可以100%成功
ping 192.168.3.5 不同交換機 同一vlan
同樣 ping 同樣第一次存在丟包;第二次 100%成功
【完工 】
///////////////////////////////////////////////華麗分割線///////////////////////////////////////////////////////////////////////
各位客官老爺 若在實現過程中 出現問題,歡迎指正錯誤。
By sizaif version: 1.01
///////////////////////////////////////////////華麗分割線///////////////////////////////////////////////////////////////////////