1、添加硬件服務器
一、增長一臺router c3600,點配置,到Slots,增長兩個NM-1FE-TX,開機並命名爲dhcpide
二、增長一臺router c3600,點配置,到Slots,增長一個NM-16ESW(使這臺機成爲交換機),開機並命名爲relay測試
三、增長一臺hostspa
四、dhcp的f0/0鏈接reply的f0/0,host的nio_udp:30000接reply的f0/1,host的nio_udp:30001接reply的f0/2orm
2、設置dhcp的ip、默認路由、dhcp池router
dhcp池:server
dhcp(config)#ip dhcp pool vl2dns
dhcp(dhcp-config)#network 192.168.2.0 255.255.255.0ip
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
3、設置relay的vlan與使交換機成爲dhcp中繼
一、添加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
二、把f0/0 - 1設置爲vlan二、把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
三、開啓路由功能、設定爲dhcp中繼
relay(config)#ip routing
relay(config)#service dhcp
relay(config)#ip dhcp relay information option
四、設置DHCP服務器地址
relay(config)#int vlan 3
relay(config-if)#ip helper-address 192.168.2.254
4、在pc機中測試
在gns的目錄找到vpcs並運行,在pc1的cmd中輸入ip dhcp,得到ip192.168.2.XX後,輸入2,切換到pc2,在cmd中輸入ip dhcp,得到ip192.168.3.XX,則證實不一樣的vlan得到不一樣網段的ip,又能ping通不一樣網段,則證實dhcp中繼配置成功。