3、DHCP服务开启后我们回到GNS3中,开启添加的3层交换机与2层交换机,并双击进入3层交换设备与2层交换设备,在2层交换设备中配置vlan,并将接入链路分别接入相对应的vlan中,将f1/0接口配置为trunk链路,在3层交换设备中同样设置vlan,然后进入vlan中配置IP地址,并指定IP地址192.168.100.100可以通过vlan在局域网中通信,最后将f1/0接口同样配置为trunk链路。

sw2#conf t
//在2层交换设备中进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
sw2(config)#vlan 10,20,100 //配置vlan10、20、100
sw2(config-vlan)#ex
//退出vlan接口
sw2(config)#do show vlan-sw b //查看vlna是否配置成功
VLAN Name
Status Ports
---- -------------------------------- --------- -------------------------------
1 default
active Fa1/0, Fa1/1, Fa1/2, Fa1/3
Fa1/4, Fa1/5, Fa1/6, Fa1/7
Fa1/8, Fa1/9, Fa1/10, Fa1/11
Fa1/12, Fa1/13, Fa1/14, Fa1/15
10 VLAN0010
active
20 VLAN0020
active //配置的vlan
100 VLAN0100
active
1002 fddi-default
act/unsup
1003 token-ring-default
act/unsup
1004 fddinet-default
act/unsup
1005 trnet-default
act/unsup
sw2(config)#int f1/1
//进入f1/1接口
sw2(config-if)#sw m acc //进入配置链路
sw2(config-if)#sw acc vlan 100 //将链路接入vlan100
sw2(config-if)#ex
//退出
sw2(config)#int f1/2
//进入f1/2接口
sw2(config-if)#sw m acc
//进入配置链路
sw2(config-if)#sw acc vlan 10 //将链路接入vlan10
sw2(config-if)#ex
//退出
sw2(config)#int f1/3
//进入f1/3接口
sw2(config-if)#sw m acc
//进入配置链路
sw2(config-if)#sw acc vlan 20 //将链路接入vlan20
sw2(config-if)#ex
//退出
sw2(config)#do show vlan-sw b //查看vlna
VLAN Name
Status Ports
---- -------------------------------- --------- -------------------------------
1 default
active Fa1/0, Fa1/4, Fa1/5, Fa1/6
Fa1/7, Fa1/8, Fa1/9, Fa1/10
Fa1/11, Fa1/12, Fa1/13, Fa1/14
Fa1/15
10 VLAN0010
active Fa1/2
20 VLAN0020
active Fa1/3
//链路成功接入vlan
100 VLAN0100
active Fa1/1
1002 fddi-default
act/unsup
1003 token-ring-default
act/unsup
1004 fddinet-default
act/unsup
1005 trnet-default
act/unsup
sw2(config)#int f1/0
//进入f1/0接口
sw2(config-if)#sw m t
//将接口配置为trunk
sw2(config-if)#sw t en do
//在trunk链路中封装dot1q协议
sw2(config-if)#ex
//退出
sw2(config)#do show int f1/0 switchport //查看接口是否配置成功
Name: Fa1/0
Switchport: Enabled
Administrative Mode: trunk
//成功配置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,10,20,100
Protected: false
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
sw2(config)#no ip routing //关闭2层交换设备路由功能
sw3(config)#vlan 10,20,100 //在3层交换设备中配置vlan10、20、100
sw3(config-vlan)#ex
//退出
sw3(config)#do show vlan-sw b //查看vlan
VLAN Name
Status Ports
---- -------------------------------- --------- -------------------------------
1 default
active Fa1/0, Fa1/1, Fa1/2, Fa1/3
Fa1/4, Fa1/5, Fa1/6, Fa1/7
Fa1/8, Fa1/9, Fa1/10, Fa1/11
Fa1/12, Fa1/13, Fa1/14, Fa1/15
10 VLAN0010
active
20 VLAN0020
active
//配置成功
100 VLAN0100
active
1002 fddi-default
act/unsup
1003 token-ring-default
act/unsup
1004 fddinet-default
act/unsup
1005 trnet-default
act/unsup
sw3(config)#int vlan 10
//进入虚拟接口vlan10
sw3(config-if)#ip add 192.168.10.1 255.255.255.0 //在接口中添加IP地址
sw3(config-if)#ip helper-address 192.168.100.100 //指定IP地址192.168.100.100可通过接口
sw3(config-if)#no shut
//开启配置
sw3(config-if)#ex
//退出
sw3(config)#int vlan 20
//进入虚拟接口vlan20
sw3(config-if)#ip add 192.168.20.1 255.255.255.0 //在接口中添加IP地址
sw3(config-if)#ip helper-address 192.168.100.100 //指定IP地址192.168.100.100可通过接口
sw3(config-if)#no shut
//开启配置
sw3(config-if)#ex
//退出
sw3(config)#int vlan 100
//进入虚拟接口vlan100
sw3(config-if)#ip add 192.168.100.1 255.255.255.0 //在接口中添加IP地址
sw3(config-if)#ip helper-address 192.168.100.100 //指定IP地址192.168.100.100可通过接口
sw3(config-if)#no shut
//开启配置
sw3(config-if)#ex
//退出
sw3(config)#int f1/0
//进入f1/0 接口
sw3(config-if)#sw m t
//配置为trunk链路
*Mar 1 00:22:18.607: %DTP-5-TRUNKPORTON: Port Fa1/0 has become dot1q trunk
*Mar 1 00:22:19.111: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
*Mar 1 00:22:19.119: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
*Mar 1 00:22:19.127: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100, changed state to up
sw3(config-if)#sw t en do //封装协议
sw3(config-if)#ex
//突出
sw3(config)#do show int f1/0 switchport //查看trunk是否配置成功
Name: Fa1/0
Switchport: Enabled
Administrative Mode: trunk
//成功配置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,10,20,100
Protected: false
Priority for untagged frames: 0
Override vlan tag priority: FALSE
Voice VLAN: none
Appliance trust: none
sw3(config)#do show ip int b
//查看IP地址是否配入vlan,是否开启
Interface
IP-Address
OK? Method Status
Protocol
FastEthernet0/0
unassigned
YES unset administratively down down
FastEthernet0/1
unassigned
YES unset administratively down down
FastEthernet1/0
unassigned
YES unset up
up
FastEthernet1/1
unassigned
YES unset up
down
...//省略部分内容...
FastEthernet1/14
unassigned
YES unset up
down
FastEthernet1/15
unassigned
YES unset up
down
Vlan1
unassigned
YES unset up
up
Vlan10
192.168.10.1 YES manual up
up
Vlan20
192.168.20.1 YES manual up
up
Vlan100
192.168.100.1 YES manual up
up
//成功配入,并开启
4、完成配置后我们来查看虚拟机客户端win 10、win 7是否自动获取IP地址