一、打開Cisco Packet Tracer
1.創建PC0,PC1,PC2,PC3和一臺交換機,並用直通線連接
PC0---交換機fa0/1
PC1--交換機fa0/2
PC2---交換機fa0/3
PC3--交換機fa0/4
二、.進入交換機CLI
1.進入特權模式
Switch>enable
Switch#
2.進入配置模式
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
3.分別創建兩個vlan (10,20)
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#ex
4.配置fa0/1,fa0/2 並加入vlan 10
Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#sw acc vlan 10
Switch(config-if)#no sh
Switch(config-if)#ex
Switch(config)#int
Switch(config)#int fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#sw acc vlan 10
Switch(config-if)#no sh
Switch(config-if)#ex
5.配置fa0/3,fa0/4加入vlan20
Switch(config)#int fa0/3
Switch(config-if)#switchport mode access
Switch(config-if)#sw acc vlan 20
Switch(config-if)#no sh
Switch(config-if)#ex
Switch(config)#int fa0/4
Switch(config-if)#switchport mode access
Switch(config-if)#sw acc vlan 20
Switch(config-if)#no sh
Switch(config-if)#ex
6.配置vlan10,vlan20的ip地址
Switch(config)#int 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 address 192.168.1.1 255.255.255.0
Switch(config-if)#int 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 address 192.168.2.1 255.255.255.0
三、進入PC進行配置
PC0:192.168.1.2 255.255.255.0 網關 192.168.1.1
PC1:192.168.1.3 255.255.255.0 網關 192.168.1.1
PC3:192.168.2.2 255.255.255.0 網關 192.168.2.1
PC4:192168.2.3 255.255.255.0 網關 192.168.2.1
這裏只截圖一張
四、測試
1.打開PC0控制檯
C:\>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::203:E4FF:FE82:EC5D
IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1
Bluetooth Connection:
Link-local IPv6 Address.........: ::
IP Address......................: 0.0.0.0
Subnet Mask.....................: 0.0.0.0
Default Gateway.................: 0.0.0.0
C:\>ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
Reply from 192.168.1.3: bytes=32 time=5ms TTL=128
Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.1.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 5ms, Average = 1ms
C:\>ping 192.168.2.1
Pinging 192.168.2.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.2.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
2.打開PC2控制檯
C:\>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::209:7CFF:FEE3:DAE6
IP Address......................: 192.168.2.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.2.1
Bluetooth Connection:
Link-local IPv6 Address.........: ::
IP Address......................: 0.0.0.0
Subnet Mask.....................: 0.0.0.0
Default Gateway.................: 0.0.0.0
C:\>ping 192.168.2.3
Pinging 192.168.2.3 with 32 bytes of data:
Reply from 192.168.2.3: bytes=32 time<1ms TTL=128
Reply from 192.168.2.3: bytes=32 time<1ms TTL=128
Reply from 192.168.2.3: bytes=32 time<1ms TTL=128
Reply from 192.168.2.3: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.2.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\>ping 192.168.1.2
Pinging 192.168.1.2 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.1.2:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
C:\>
完畢!個人原創,如有錯誤歡迎討論,勿噴!