实验目的

1、理解Trunk的运行原理

2、掌握Trunk的配置方法

实验拓扑

实验需求

1、根据实验拓扑图,完成设备的基本配置;

2、分别在SW1和SW2创建VLAN10和VLAN20,名字为IT和HR;

3、分别在SW1和SW2上把相应的接口划入VLAN10和VLAN20;

4、把SW1和SW2互连的链路配置成Trunk,采用Dot1q封装;

5、测试PC之间的网络连通性。

实验步骤

步骤1:设备的基本配置

配置PC1

VPCS> set pcname PC1 //设置主机名

PC1> ip 10.1.1.1/24 //设置IP地址

配置PC2

VPCS> set pcname PC2

PC2> ip 10.1.2.1/24

配置PC3

VPCS> set pcname PC3

PC3> ip 10.1.1.2/24

配置PC4

VPCS> set pcname PC4

PC4> ip 10.1.2.2/24

配置SW1

Switch>enable

Switch#configure terminal

Switch(config)#hostname SW1

SW1(config)#no ip domain-lookup

SW1(config)#line console 0

SW1(config-line)#exec-timeout 0 0

SW1(config-line)#logging synchronous

SW1(config-line)#end

SW1#

配置SW2

Switch>enable

Switch#configure terminal

Switch(config)#hostname SW2

SW2(config)#no ip domain-lookup

SW2(config)#line console 0

SW2(config-line)#exec-timeout 0 0

SW2(config-line)#logging synchronous

SW2(config-line)#end

SW2#

步骤2:VLAN的配置

配置SW1

SW1(config)#vlan 10

SW1(config-vlan)#name IT

SW1(config-vlan)#exit

SW1(config)#vlan 20

SW1(config-vlan)#name HR

SW1(config-vlan)#exit

SW1(config)#interface Eth0/1

SW1(config-if)#switchport mode access

SW1(config-if)#switchport access vlan 10

SW1(config-if)#exit

SW1(config)#interface Eth0/2

SW1(config-if)#switchport mode access

SW1(config-if)#switchport access vlan 20

SW1(config-if)#end

SW1#

配置SW2

SW2(config)#vlan 10

SW2(config-vlan)#name IT

SW2(config-vlan)#exit

SW2(config)#vlan 20

SW2(config-vlan)#name HR

SW2(config-vlan)#exit

SW2(config)#interface Eth0/1

SW2(config-if)#switchport mode access

SW2(config-if)#switchport access vlan 10

SW2(config-if)#exit

SW2(config)#interface Eth0/2

SW2(config-if)#switchport mode access

SW2(config-if)#switchport access vlan 20

SW2(config-if)#end

SW2#

步骤3:Trunk的配置

配置SW1

SW1(config)#interface Eth0/0

SW1(config-if)#switchport trunk encapsulation dot1q

SW1(config-if)#switchport mode trunk

SW1(config-if)#end

SW1#

配置SW2

SW2(config)#interface Eth0/0

SW2(config-if)#switchport trunk encapsulation dot1q

SW2(config-if)#switchport mode trunk

SW2(config-if)#end

SW2#

实验检查

步骤1:检查VLAN

检查SW1

SW1#show vlan brief

VLAN Name Status Ports


1 default active Et0/3

10 IT active Et0/1

20 HR active Et0/2

1002 fddi-default act/unsup

1003 token-ring-default act/unsup

1004 fddinet-default act/unsup

1005 trnet-default act/unsup

SW1已经创建好VLAN10和VLAN20,并已将对应接口划入。

检查SW2

SW2#show vlan brief

VLAN Name Status Ports


1 default active Et0/3

10 IT active Et0/1

20 HR active Et0/2

1002 fddi-default act/unsup

1003 token-ring-default act/unsup

1004 fddinet-default act/unsup

1005 trnet-default act/unsup

SW2已经创建好VLAN10和VLAN20,并已将对应接口划入。

步骤2:检查Trunk

检查SW1

SW1#show interfaces Eth0/0 switchport

Name: Et0/0

Switchport: Enabled

Administrative Mode: trunk

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)

Administrative Native VLAN tagging: enabled

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 Native VLAN tagging: enabled

Administrative private-vlan trunk encapsulation: dot1q

Administrative private-vlan trunk normal VLANs: none

Administrative private-vlan trunk associations: none

Administrative private-vlan trunk mappings: none

Operational private-vlan: none

Trunking VLANs Enabled: ALL

Pruning VLANs Enabled: 2-1001

Capture Mode Disabled

Capture VLANs Allowed: ALL

Protected: false

Appliance trust: none

E0/0接口当前是Trunk,封装的协议是dot1q。

SW1#show interfaces trunk

Port Mode Encapsulation Status Native vlan

Et0/0 on 802.1q trunking 1

Port Vlans allowed on trunk

Et0/0 1-4094

Port Vlans allowed and active in management domain

Et0/0 1,10,20

Port Vlans in spanning tree forwarding state and not pruned

Et0/0 1,10,20

E0/0封装的Trunk协议是dot1q,当前的状态是trunking。

SW1#sh run int Eth0/0

Building configuration...

Current configuration : 90 bytes

!

interface Ethernet0/0

switchport trunk encapsulation dot1q

switchport mode trunk

end

E0/0接口的Trunk封装协议是dot1q,模式是trunk。

检查SW2

SW2#show interfaces trunk

Port Mode Encapsulation Status Native vlan

Et0/0 on 802.1q trunking 1

Port Vlans allowed on trunk

Et0/0 1-4094

Port Vlans allowed and active in management domain

Et0/0 1,10,20

Port Vlans in spanning tree forwarding state and not pruned

Et0/0 1,10,20

E0/0封装的Trunk协议是dot1q,当前的状态是trunking。

步骤4:网络连通性测试

测试PC1和PC3的连通性:

PC1> ping 10.1.1.2

84 bytes from 10.1.1.2 icmp_seq=1 ttl=64 time=1.603 ms

84 bytes from 10.1.1.2 icmp_seq=2 ttl=64 time=1.234 ms

84 bytes from 10.1.1.2 icmp_seq=3 ttl=64 time=1.027 ms

84 bytes from 10.1.1.2 icmp_seq=4 ttl=64 time=2.372 ms

84 bytes from 10.1.1.2 icmp_seq=5 ttl=64 time=1.200 ms

PC1和PC3的网络连通性正常。

测试PC2和PC4的连通性:

PC2> ping 10.1.2.2

84 bytes from 10.1.2.2 icmp_seq=1 ttl=64 time=0.887 ms

84 bytes from 10.1.2.2 icmp_seq=2 ttl=64 time=0.932 ms

84 bytes from 10.1.2.2 icmp_seq=3 ttl=64 time=1.295 ms

84 bytes from 10.1.2.2 icmp_seq=4 ttl=64 time=0.926 ms

84 bytes from 10.1.2.2 icmp_seq=5 ttl=64 time=1.011 ms

PC2和PC4的网络连通性正常。

原文来自:微思网络
原文地址:https://mp.weixin.qq.com/s/EA...


微思郭仔
31 声望2 粉丝

微思IT认证培训-思科、华为、红帽、oracle、VMware、PMP、CISP等,一切为了成为更好的自己,加油!!!