一、添加硬件
1、增加一台router c3600,点配置,到Slots,增加两个NM-1FE-TX,开机并命名为dhcp
2、增加一台router c3600,点配置,到Slots,增加一个NM-16ESW(使这台机成为交换机),开机并命名为relay
3、增加一台host
4、dhcp的f0/0连接reply的f0/0,host的nio_udp:30000接reply的f0/1,host的nio_udp:30001接reply的f0/2
二、设置dhcp的ip、默认路由、dhcp池
dhcp池:
dhcp(config)#ip dhcp pool vl2
dhcp(dhcp-config)#network 192.168.2.0 255.255.255.0
dhcp(dhcp-config)#default-router 192.168.2.253
dhcp(dhcp-config)#dns-server 202.86.20.3
dhcp(dhcp-config)#exit
dhcp(config)#ip dhcp pool vl3
dhcp(dhcp-config)#network 192.168.3.0 255.255.255.0
dhcp(dhcp-config)#default-router 192.168.3.253
dhcp(dhcp-config)#dns-server 202.86.20.3
dhcp(dhcp-config)#exit
ip地址:
dhcp(config)#int f 0/0
dhcp(config-if)#ip address 192.168.2.254 255.255.255.0
dhcp(config-if)#no sh
dhcp(config-if)#exit
指定不分配的ip:
dhcp(config)#ip dhcp excluded-address 192.168.2.250 192.168.2.254
dhcp(config)#ip dhcp excluded-address 192.168.3.250 192.168.3.254
设置默认路由:
dhcp(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.253
三、设置relay的vlan与使交换机成为dhcp中继
1、添加vlan
relay#vlan database
relay(vlan)#vlan 2 name it
VLAN 2 added:
Name: it
relay(vlan)#vlan 3 name cw
VLAN 3 added:
Name: cw
relay(vlan)#exit
APPLY completed.
Exiting....
relay#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
relay(config)#int vlan 2
relay(config-if)#ip address 192.168.2.253 255.255.255.0
relay(config-if)#no sh
relay(config-if)#exit
relay(config)#int vlan 2
relay(config-if)#ip address 192.168.3.253 255.255.255.0
relay(config-if)#no sh
relay(config-if)#exit
2、把f0/0 - 1设置为vlan2、把f0/2 - 3设置为vlan3
relay(config)#int range fastEthernet 0/0 - 1
relay(config-if-range)#switchport mode access
relay(config-if-range)#switchport access vlan 2
relay(config-if-range)#spanning-tree portfast
relay(config-if-range)#exit
relay(config)#int range fastEthernet 0/0 - 1
relay(config-if-range)#switchport mode access
relay(config-if-range)#switchport access vlan 2
relay(config-if-range)#spanning-tree portfast
relay(config-if-range)#exit
3、开启路由功能、设定为dhcp中继
relay(config)#ip routing
relay(config)#service dhcp
relay(config)#ip dhcp relay information option
4、设置DHCP服务器地址
relay(config)#int vlan 3
relay(config-if)#ip helper-address 192.168.2.254
四、在pc机中测试
在gns的目录找到vpcs并运行,在pc1的cmd中输入ip dhcp,获得ip192.168.2.XX后,输入2,切换到pc2,在cmd中输入ip dhcp,获得ip192.168.3.XX,则证明不同的vlan获得不同网段的ip,又能ping通不同网段,则证明dhcp中继配置成功。
原文地址:http://8540864.blog.51cto.com/8530864/1620741