计算机网络原理实验二──二层交换机基本配置
2021-4-23
| 2023-3-27
0  |  0 分钟
type
Post
status
Published
date
Apr 23, 2021
slug
Principles-Of-Computer-Networks-Experiment-2
summary
先在 CPT(Cisco Packet Tracer) 上放置两个PC,两个Switch,然后将PC与各自的 Switch 通过 Copper Straight-Through 连接,交换机之间通过 Copper Cross-over 连接,此处两个 Switch 使用 2950-24 型号,将Switch的0/1口和PC进行连接,将Switch的0/24口相互连接。 我们的目的是将这四个设备划分在一个 VLAN(VLAN 10) 中。
tags
学习
category
学习思考
icon
password

预先准备

先在 CPT(Cisco Packet Tracer) 上放置两个PC,两个Switch,然后将PC与各自的 Switch 通过 Copper Straight-Through 连接,交换机之间通过 Copper Cross-over 连接,此处两个 Switch 使用 2950-24 型号,将Switch的0/1口和PC进行连接,将Switch的0/24口相互连接。
我们的目的是将这四个设备划分在一个 VLAN(VLAN 10) 中。

接口与 VLAN 配置

查看vlan信息

双击 Switch 打开 CLI,默认是用户模式,输入enable进入特权模式,输入 show vlan 即可查看目前的VLAN状况,由此可见接口都默认接在VLAN1上。
Switch>enable Switch#show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ Switch#
输入 show running-config 也可以查看目前接口配置情况,输入 show history 可以查看命令执行历史记录

将接口划分到vlan

首先进入全局配置模式下,输入 configure terminal ,然后输入vlan 10创建新的vlan
Switch# %SYS-5-CONFIG_I: Configured from console by console configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 10 Switch(config-vlan)#do show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 10 VLAN0010 active 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 10 enet 100010 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ Switch(config-vlan)#〔筆畫〕
可以看到上面多了一个vlan 10
Switch(config-vlan)# interface fastEthernet 0/1 Switch(config-if)#switchport access vlan 10 Switch(config-if)#do show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5 Fa0/6, Fa0/7, Fa0/8, Fa0/9 Fa0/10, Fa0/11, Fa0/12, Fa0/13 Fa0/14, Fa0/15, Fa0/16, Fa0/17 Fa0/18, Fa0/19, Fa0/20, Fa0/21 Fa0/22, Fa0/23, Fa0/24 10 VLAN0010 active Fa0/1 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 10 enet 100010 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ Switch(config-if)# %CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/1 (10), with Switch FastEthernet0/1 (1).
然后修改 0/24 端口,此处要修改端口模式
Switch(config-if)#interface fastEthernet 0/24 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

更改PC的IP地址

各配置192.168.1.1(2),关闭保存,打开Command Prompt,尝试互相ping
C:\>ping 192.168.1.2 Pinging 192.168.1.2 with 32 bytes of data: Reply from 192.168.1.2: bytes=32 time=22ms TTL=128 Reply from 192.168.1.2: bytes=32 time<1ms TTL=128 Reply from 192.168.1.2: bytes=32 time<1ms TTL=128 Reply from 192.168.1.2: bytes=32 time=1ms TTL=128 Ping statistics for 192.168.1.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 22ms, Average = 5ms C:\>
配置成功

其他

输错指令进入域名解析

按 Ctrl+Shift+6 快捷键取消操作
 

Preparation

First, let's put two PCs and two switches(non-nintendo) into the Cisco Packet Tracer. The Cisco Packet Tracer can be downloaded here. Then connect two PCs to their own switch by Copper Straight-Through Line. It is important to keep in mind that you should use Copper Cross-over Line to connect two switches. We use the switch model 2950-24 here. Connect FastEthernet 0/1 of the switch with the port of the PC, and then connect FastEthernet 0/24 of the two switches each other.

Configuration of Interface and VLAN

View the information of VLAN

Double Click one of the switches and switch to CLI tab, whose default mode's User Mode. You should type "enable" to enter privilege mode. You can type "show vlan" to view the status of VLAN. By default, all interfaces are on vlan1.
 
Switch>enable Switch#show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ Switch#
To view the information of the current interface, type "show running-config". To view the command history, type "show history".
 

Divide the interface into the custom vlan

First, type "configure terminal" to enter global configuration mode. Then type "vlan 10" to create a new vlan. Type "do show vlan" after that, you will find the newly created vlan.
 
Switch# %SYS-5-CONFIG_I: Configured from console by console configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 10 Switch(config-vlan)#do show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 10 VLAN0010 active 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 10 enet 100010 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ Switch(config-vlan)#〔筆畫〕
 
Switch(config-vlan)# interface fastEthernet 0/1 Switch(config-if)#switchport access vlan 10 Switch(config-if)#do show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5 Fa0/6, Fa0/7, Fa0/8, Fa0/9 Fa0/10, Fa0/11, Fa0/12, Fa0/13 Fa0/14, Fa0/15, Fa0/16, Fa0/17 Fa0/18, Fa0/19, Fa0/20, Fa0/21 Fa0/22, Fa0/23, Fa0/24 10 VLAN0010 active Fa0/1 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 10 enet 100010 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ Switch(config-if)# %CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/1 (10), with Switch FastEthernet0/1 (1).
Then change the mode of fastEthernet 0/24 to trunk mode.
Switch(config-if)#interface fastEthernet 0/24 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

Set IP Address for PCs

Set the IP of PC1 to 192.168.1.1, set the IP of PC2 to 192.168.1.2, then close the window to save the configuration. Open the Command Prompt. Try pinging PC2 from PC1, you're cool when you got the reply from PC2.
C:\>ping 192.168.1.2 Pinging 192.168.1.2 with 32 bytes of data: Reply from 192.168.1.2: bytes=32 time=22ms TTL=128 Reply from 192.168.1.2: bytes=32 time<1ms TTL=128 Reply from 192.168.1.2: bytes=32 time<1ms TTL=128 Reply from 192.168.1.2: bytes=32 time=1ms TTL=128 Ping statistics for 192.168.1.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 22ms, Average = 5ms C:\>

Other Problem

Incorrectly Enter Command and Go to Resolving Domain

Press Ctrl+Shift+6 to cancel the operation.
 

At the End

From now on, I will try to use Chinese and English in each post. I want to improve my English by doing this. So if you find a mistake in the post, or even a grammatical mistake, please leave a message below the article. It is my pleasure to listen to your criticisms and suggestions!
 
学习思考
  • 学习
  • 计算机网络原理实验四──路由器基本配置来!试试用 iPad 来写代码吧!
    目录