Date : 2021-10-23
实验软件:【GNS3模拟器、SecureCRT】后续DTP实验需要用Cisco Packet Tracer上做。建议直接使用Packet Tracer。
四台个人主机和两个交换机组成。
- 为每台PC配置IP地址
- 为每台交换机配置vlan
- 更改交换机接口的状态,查看接口状态协商结果
PC名称 | IP地址 | 子网掩码 |
---|---|---|
A1 | 192.168.1.1 | 255.255.255.0 |
A2 | 192.168.1.2 | 255.255.255.0 |
A3 | 192.168.1.3 | 255.255.255.0 |
B1 | 192.168.1.4 | 255.255.255.0 |
B2 | 192.168.1.5 | 255.255.255.0 |
注意:
- Packet Tracer给PC机配置IP如下图所示:
- PC机命令行打开方式:
- Packet Tracer默认不是特权模式,使用enable命令进入特权模式。
> enable # ...
A1:(其他PC机同理)
A1# config terminal
A1(config)# interface f0/0
A1(config-if)# ip address 192.168.1.1 255.255.255.0
A1(config-if)# no shutdown
A1(config-if)# end
A1#
使用ping 255.255.255.255 repeat 1发送受限广播(只发送一个包,避免多个包干扰)
在A1处使用。
A1# ping 255.255.255.255 repeat 1
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 255.255.255.255, timeout is 2 seconds:
Reply to request 0 from 192.168.1.3, 108 ms
Reply to request 0 from 192.168.1.4, 108 ms
Reply to request 0 from 192.168.1.2, 108 ms
Reply to request 0 from 192.168.1.5, 108 ms
注:当前使用c3640关闭三层路由功能模拟二层交换机,由于ios太旧,使用的vlan配置命令比较旧。
VLAN number | VLAN name | switchport |
---|---|---|
2 | tech | switch1: f0/1, f0/3 |
3 | sales | switch2: f0/1, f0/2; switch1: f0/2 |
Switch1# vlan database
Switch1(vlan)# vlan 2 name tech
VLAN 2 added:
Name: tech
Switch1(vlan)# vlan 3 name sales
VLAN 3 added:
Name: sales
Switch1(vlan)# exit
APPLY completed.
Exiting....
Switch1# config terminal
Switch1(config)# interface f0/1
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 2
Switch1(config-if)# exit
Switch1(config)# interface f0/2
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 3
Switch1(config-if)# exit
Switch1(config)# interface f0/3
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 2
Switch1(config-if)# exit
Switch1(config)# interface f0/11
Switch1(config-if)# switchport mode trunk
Switch1(config-if)# end
Switch2# vlan database
Switch2(vlan)# vlan 3 name sales
VLAN 3 added:
Name: sales
Switch2(vlan)# exit
APPLY completed.
Exiting....
Switch2# config terminal
Switch2(config)# interface f0/1 - 2
Switch2(config-if-range)# switchport mode access
Switch2(config-if-range)# switchport access vlan 3
Switch2(config-if-range)# exit
Switch2(config)# interface f0/11
Switch2(config-if)# switchport mode trunk
Switch2(config-if)# end
查询vlan配置信息:在模拟器中的命令是show vlan-switch,在现实设备上的命令是show vlan。
查询接口的vlan信息命令:show interface 接口标识 switchport
switch1的预期查询结果:switch1中的f0/1,f0/3都是vlan3状态是access;
switch1上的f0/2是vlan3状态是access;
switch1上的f0/11是vlan3状态是trunk.
switch2的预期查询结果:switch2中的f0/1,f0/2都是vlan3状态是access;
switch2上的f0/11是vlan3状态是trunk.
Switch1# show vlan-switch
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/12, Fa0/13, Fa0/14, Fa0/15
2 tech active Fa0/1, Fa0/3
3 sales active Fa0/2
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 - - - - - 1002 1003
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 1 1003
1003 tr 101003 1500 1005 0 - - srb 1 1002
1004 fdnet 101004 1500 - - 1 ibm - 0 0
1005 trnet 101005 1500 - - 1 ibm - 0 0
Switch1# show interface f0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: native
Negotiation of Trunking: Disabled
Access Mode VLAN: 2 (tech)
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 2
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
Switch1# show interface f0/2 switchport
Name: Fa0/2
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: native
Negotiation of Trunking: Disabled
Access Mode VLAN: 3 (sales)
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 3
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
Switch1# show interface f0/11 switchport
Name: Fa0/11
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 1-3
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
Switch2# show vlan-switch
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/12, Fa0/13, Fa0/14
Fa0/15
3 sales active Fa0/1, Fa0/2
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 - - - - - 1002 1003
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 1 1003
1003 tr 101003 1500 1005 0 - - srb 1 1002
1004 fdnet 101004 1500 - - 1 ibm - 0 0
1005 trnet 101005 1500 - - 1 ibm - 0 0
Switch2# show interface f0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: native
Negotiation of Trunking: Disabled
Access Mode VLAN: 3 (sales)
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 3
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
Switch2# show interface f0/11 switchport
Name: Fa0/11
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
Trunking Native Mode VLAN: 1 (default)
Trunking VLANs Enabled: ALL
Trunking VLANs Active: 1,3
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
- 因为A1和A3在一个虚拟局域网中,所以A1可以ping通A3,而不能ping通A2、B1、B2。
- 因为A2和B1、B2在一个虚拟局域网中,所以A2能ping通B1和B2,而不能ping通A1和A2。
A1# ping 255.255.255.255 repeat 1
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 255.255.255.255, timeout is 2 seconds:
Reply to request 0 from 192.168.1.3, 20 ms
A2# ping 255.255.255.255 repeat 1
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 255.255.255.255, timeout is 2 seconds:
Reply to request 0 from 192.168.1.4, 20 ms
Reply to request 0 from 192.168.1.5, 20 ms
注:GNS3软件无法做DTP实验,以下改换成Cisco Packet Tracer软件做的。
问题一:将Switch1和Switch2都设置为negotiate模式,考察以下组合,哪些可以形成Trunk?
- | Switch2 - trunk | Switch2 - dynamic desirable | Switch2 - dynamic auto |
---|---|---|---|
Switch1 - trunk | trunk | trunk | trunk |
Switch1 - dynamic desirable | trunk | trunk | trunk |
Switch1 - dynamic auto | trunk | trunk | access |
问题二:将Switch1设置为nonegotiate模式,Switch2仍为negotiate模式,再考察以下组合,哪些可以形成Trunk?在配置时与两者都是negotiate模式时有什么区别?注意:考虑将Switch1设置为nonegotiate模式时,Switch1还能否设置为dynamic desirable或dynamic auto模式?
- | Switch2 - trunk | Switch2 - dynamic desirable | Switch2 - dynamic auto |
---|---|---|---|
Switch1 - trunk | trunk | trunk | trunk |
Switch1 - dynamic desirable | - | - | - |
Switch1 - dynamic auto | - | - | - |
问题分析
通过下面的配置方法,把上面的3*3的状态都设置一遍。
Switch1# config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch1(config)#int f0/11
Switch1(config-if)# shutdown
%LINK-5-CHANGED: Interface FastEthernet0/11, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/11, changed state to down
Switch1(config-if)# switchport mode dynamic desirable
Switch1(config-if)# no shutdown
Switch2# config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch2(config)# interface f0/11
Switch2(config-if)# shutdown
%LINK-5-CHANGED: Interface FastEthernet0/11, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/11, changed state to down
Switch2(config-if)# switchport mode dynamic auto
Switch2(config-if)# no shutdown
Switch1# config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface f0/11
Switch(config-if)# shutdown
%LINK-5-CHANGED: Interface FastEthernet0/11, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/11, changed state to down
Switch(config-if)# switchport nonegotiate
Command rejected: Conflict between 'nonegotiate' and 'dynamic' status.
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport nonegotiate
Switch(config-if)# no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/11, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/11, changed state to up
Switch(config-if)# end
注意:Command rejected: Conflict between ‘nonegotiate’ and ‘dynamic’ status. 说明nonegotiate状态下接口不能是dynamic模式。
通过show interface f0/11 switchport命令观察接口状态。
Switch1# show interface f0/11 switchport
Name: Fa0/11
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: All
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none
Switch2# show interface f0/11 switchport
Name: Fa0/11
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: All
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none