一、新建立VLAN2并配置
switch>en //进入特权模式
switch#con //进入全局配置模式
switch(Config)#l3-forward enable //开启三层转发协议
switch(Config)#vlan 2 //建立VLAN2
switch(Config-Vlan2)#switchport interface ethernet 0/0/2-20 //给VLAN2分配端口
Set the port Ethernet0/0/2 access vlan 2 successfully
Set the port Ethernet0/0/3 access vlan 2 successfully
Set the port Ethernet0/0/4 access vlan 2 successfully
Set the port Ethernet0/0/5 access vlan 2 successfully
Set the port Ethernet0/0/6 access vlan 2 successfully
Set the port Ethernet0/0/7 access vlan 2 successfully
Set the port Ethernet0/0/8 access vlan 2 successfully
Set the port Ethernet0/0/9 access vlan 2 successfully
Set the port Ethernet0/0/10 access vlan 2 successfully
Set the port Ethernet0/0/11 access vlan 2 successfully
Set the port Ethernet0/0/12 access vlan 2 successfully
Set the port Ethernet0/0/13 access vlan 2 successfully
Set the port Ethernet0/0/14 access vlan 2 successfully
Set the port Ethernet0/0/15 access vlan 2 successfully
Set the port Ethernet0/0/16 access vlan 2 successfully
Set the port Ethernet0/0/17 access vlan 2 successfully
Set the port Ethernet0/0/18 access vlan 2 successfully
Set the port Ethernet0/0/19 access vlan 2 successfully
Set the port Ethernet0/0/20 access vlan 2 successfully
switch(Config-Vlan2)#interface vlan 2 //进入虚拟三层管理端口
%Jan 01 00:11:50 2001 %LINK-5-CHANGED: Interface Vlan2, changed state to UP
switch(Config-If-Vlan2)#ip address 192.168.2.1 255.255.255.0 //给VLAN2分配管理地址
switch(Config-If-Vlan2)#
~~~~~~~~~~~~~~~~~~~~~~~~vlan2配置完毕~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
二、建立VLAN3并配置
switch(Config)#vlan 3 //建立VLAN3
switch(Config-Vlan3)#switchport interface ethernet 0/0/21-52 //给VLAN3分配端口
Set the port Ethernet0/0/21 access vlan 3 successfully
Set the port Ethernet0/0/22 access vlan 3 successfully
Set the port Ethernet0/0/23 access vlan 3 successfully
Set the port Ethernet0/0/24 access vlan 3 successfully
Set the port Ethernet0/0/25 access vlan 3 successfully
Set the port Ethernet0/0/26 access vlan 3 successfully
Set the port Ethernet0/0/27 access vlan 3 successfully
Set the port Ethernet0/0/28 access vlan 3 successfully
Set the port Ethernet0/0/29 access vlan 3 successfully
Set the port Ethernet0/0/30 access vlan 3 successfully
Set the port Ethernet0/0/31 access vlan 3 successfully
Set the port Ethernet0/0/32 access vlan 3 successfully
Set the port Ethernet0/0/33 access vlan 3 successfully
Set the port Ethernet0/0/34 access vlan 3 successfully
Set the port Ethernet0/0/35 access vlan 3 successfully
Set the port Ethernet0/0/36 access vlan 3 successfully
Set the port Ethernet0/0/37 access vlan 3 successfully
Set the port Ethernet0/0/38 access vlan 3 successfully
Set the port Ethernet0/0/39 access vlan 3 successfully
Set the port Ethernet0/0/40 access vlan 3 successfully
Set the port Ethernet0/0/41 access vlan 3 successfully
Set the port Ethernet0/0/42 access vlan 3 successfully
Set the port Ethernet0/0/43 access vlan 3 successfully
Set the port Ethernet0/0/44 access vlan 3 successfully
Set the port Ethernet0/0/45 access vlan 3 successfully
Set the port Ethernet0/0/46 access vlan 3 successfully
Set the port Ethernet0/0/47 access vlan 3 successfully
Set the port Ethernet0/0/48 access vlan 3 successfully
Set the port Ethernet0/0/49 access vlan 3 successfully
Set the port Ethernet0/0/50 access vlan 3 successfully
Set the port Ethernet0/0/51 access vlan 3 successfully
Set the port Ethernet0/0/52 access vlan 3 successfully
switch(Config-Vlan3)#interface vlan 3 //进入虚拟三层管理端口
%Jan 01 00:09:14 2001 %LINK-5-CHANGED: Interface Vlan3, changed state to UP
switch(Config-If-Vlan3)#ip address 192.168.3.1 255.255.255.0 //给VLAN3分配管理地址
switch(Config-If-Vlan3)#
~~~~~~~~~~~~~~~~~~~~~~~~vlan3配置完毕~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
三、开启DHCP服务,并配置其为VLAN2分配IP地址
switch(Config)#service dhcp //全局配置模式下开启DCHP服务
switch(Config)#ip dhcp pool vlan2dhcp //建立DHCP分配地址池名称
switch(dhcp-vlan2dhcp-config)#network-address 192.168.2.0 255.255.255.0 //给新建立的地址池分配IP地址段
switch(dhcp-vlan2dhcp-config)#default-router 192.168.2.1 //给新建立的地址池分配网关
switch(dhcp-vlan2dhcp-config)#dns-server 202.96.209.133 202.96.209.5 //给新建立的地址池分配DNS服务器
switch(dhcp-vlan2dhcp-config)#lease 3 //设置地址租期为三天
switch(dhcp-vlan2dhcp-config)#exit //退出
switch(Config)#ip dhcp excluded-address 192.168.2.1 192.168.2.5 //设置排除的地址段
switch(Config)#exit //退出
switch#write //保存
四、给VLAN3分配IP地址
switch(Config)#ip dhcp pool vlan3dhcp //建立DHCP分配地址池名称
switch(dhcp-vlan3dhcp-config)#network-address 192.168.3.0 255.255.255.0 //给新建立的地址池分配IP地址段
switch(dhcp-vlan3dhcp-config)#default-router 192.168.3.1 //给新建立的地址池分配网关
switch(dhcp-vlan3dhcp-config)#dns-server 210.22.70.3 210.22.84.3 //给新建立的地址池分配DNS服务器
switch(dhcp-vlan3dhcp-config)#lease 3 //设置地址租期为三天
switch(dhcp-vlan3dhcp-config)#exit //退出
switch(Config)#ip dhcp excluded-address 192.168.3.1 192.168.3.5 //设置排除的地址段
switch(Config)#exit //退出
switch#write //保存
至此,全部配置完毕,当终端接到相应的VLAN端口时即可通过DCHP分配相应的IP地址
二、配置
DHCP
服务器
现在我们只需要在网络上找一台计算机,安装Windows 2000/2003 Server系统来充当DHCP服务器。做好准备工作之后,就可以来配置DHCP服务器了。
从控制面板的管理工具中打开DHCP项,在打开的窗口中单击“操作”菜单下的“新建作用域”命令,在打开的操作向导窗口中输入作用域的名称,单击“下一步”填写IP地址范围,分别设置起始IP地址、终止IP地址、子网掩码等信息(图1),继续单击“下一步”添加排除的IP地址范围,在这里添加的IP客户端将无法获取,主要用于服务器、路由器、防火墙等使用,随后会提示配置租约期限,默认值为8天,如果参与分配的IP地址比较少,那么该值可以设的小一些,即让IP地址交换的频率高一些,避免IP被长时间占用;当然现在内网IP地址一般都比较丰富,那么时间设置的长一些也没有关系。
图1
接下来进入DHCP选项配置窗口,即是否设置客户端的网关和DNS信息,选中“是,我现在想配置这些选项”(图2),然后单击“下一步”按钮进入“路由器(默认网关)”窗口,在“IP地址”栏中输入网关的地址,单击“添加”按钮加入,再单击“下一步”设置DNS名称,同样在“IP地址”处填入DNS服务器的IP地址并单击“添加”按钮即可,下面还会询问配置WINS服务器,一般不需要改动,直接单击“下一步”激活新建的作用域即可。
图2
重复上面的操作步骤,就可以为其它的VLAN在DHCP中创建出对应的作用域,这样就可以全部配置完成,以后就可以让DHCP与VLAN和谐相处,能够实现在多VLAN中实现DHCP服务,从此让网络能够更快速、更高效运行了。