先上拓扑图
配置步骤
1现在二成交换机上划分vlan,在把端口划分到vlan里
2在二成交换机上面开启trunk在no shutdown
3在三成交换机上面的端口封装和开启trunk
4在三成交换机上面划分vlan并给vlan配置IP地址
5在vlan里配置dhcp服务
配置命令如下:
1:Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
Switch(vlan)#exit
APPLY completed.
Exiting....
2:Switch(config)#interface range f0/1-24
Switch(config-if-range)#sw
Switch(config-if-range)#switchport ac
Switch(config-if-range)#switchport access vlan 2
3:Switch(config)#int f0/2
Switch(config-if)#sw
Switch(config-if)#switchport mode
Switch(config-if)#switchport mode trunk
三层配置
Switch(config)#int f0/2
Switch(config-if)#switchport trunk encapsulation dot1q 封装
Switch(config-if)#switchport mode trunk 开启trunk
Switch(config-if)no shutdown
添加vlan
witch(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
配置vlan地址
Switch(config)#int f0/2
Switch(config-if)#ip add 10.100.10.1 255.255.255.0
配置dhcp
Switch(config)#ip dhcp pool vlan2
Switch(dhcp-config)#network 10.100.10.0 255.255.255.0 ip地址
Switch(dhcp-config)#def
Switch(dhcp-config)#default-router 10.100.10.254 (1-253的地址池)
Switch(dhcp-config)#dns
Switch(dhcp-config)#dns-server 10.100.10.1 dns地址
网关就是配置vlan的IP地址
查看命令可以用:Switch# show vlan 和show run
查看trunk开启情况:show interfaces trunk
还可以用show interfaces switchport查看详细信息