利用3層交換機實現VLAN間的路由

  • 實驗拓撲

    wKioL1M1br-xwuXsAADXXR1vffQ434.jpg

  • 二層交換機配置

    Switch>
    Switch>en
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#vlan 10
    Switch(config-vlan)#exit
    Switch(config)#vlan 20
    Switch(config-vlan)#exit
    Switch(config)#int f 0/1
    Switch(config-if)#switchport access vlan 10
    Switch(config-if)#exit
    Switch(config)#int f 0/3 
    Switch(config-if)#switchport access vlan 20
    Switch(config-if)#exit
    Switch(config)#int f 0/2
    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)#exit
    Switch(config)#exit
    Switch#
    %SYS-5-CONFIG_I: Configured from console by console

    Switch#write
    Building configuration...
    [OK]

     

  • 三層交換機配置

    Switch>en
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#int f 0/1
    Switch(config-if)#switchport trunk encapsulation dot1q 
    Switch(config-if)#switchport mode trunk
    Switch(config-if)#exit
    Switch(config)#vlan 10
    Switch(config-vlan)#exit
    Switch(config)#vlan 20
    Switch(config-vlan)#exit
    Switch(config)#interface vlan 10
    Switch(config-if)#
    %LINK-5-CHANGED: Interface Vlan10, changed state to up

    %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

    Switch(config-if)#ip add 192.168.1.254 255.255.255.0
    Switch(config-if)#exit
    Switch(config)#interface vlan 20
    Switch(config-if)#
    %LINK-5-CHANGED: Interface Vlan20, changed state to up

    %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

    Switch(config-if)#ip add 192.168.2.254 255.255.255.0
    Switch(config-if)#exit
    Switch(config)#ip routing
    Switch(config)#exit
    Switch#
    %SYS-5-CONFIG_I: Configured from console by console

    Switch#write
    Building configuration...
    [OK]
    Switch#

  • PC0 IP設置:

  • wKioL1M1cUOjvM6TAAC1LplEIEw660.jpg

  • PC1 IP設置:

    wKiom1M1cXujgtUYAACxZ6jHt6E325.jpg

  • 測試:去PC0上PING PC1

    wKioL1M1cY3QD25SAAH90RSCn5w732.jpg

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