通过本实验掌握如何给不同网段配置DHCP,掌握DHCP中继配置,了解ip help-address 作用,了解Cisco 路由器的DHCP的配置。也许你会配置DHCP,可是可能遇到的情况是很顺利,有时你的DHCP服务器,和你DHCP 客户端,并不是在同一个网段,而是需要DHCP 给不同的网段主机分配地址。



实验拓扑:
 
p_w_picpath
实验过程:
第一步: 对路由器R1进行预配置
Router(config)#no ip do lo
Router(config)#line con 0
Router(config-line)#no exec-t
Router(config-line)#logg syn
Router(config-line)#host R1
R1(config)#do sh ip int bri
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES unset administratively down down
Serial0/0 unassigned YES unset administratively down down
Ethernet1/0 unassigned YES unset administratively down down
Serial1/0 unassigned YES unset administratively down down
R1(config)#int e0/0
//配置接口的下描述信息
R1(config-if)#description Connection to R2_E0/0
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#end
R1(config)#int e1/0
R1(config-if)#description Connection to PC1
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#
*Mar 1 00:32:04.807: %LINK-3-UPDOWN: Interface Ethernet1/0, changed state to up
*Mar 1 00:32:05.807: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet1/0, changed state to up
R1(config-if)#*Mar 1 00:09:16.631: %SYS-5-CONFIG_I: Configured from console by console
R1#conf t
*Mar 1 00:09:17.499: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//配置远程登录的用户名和密码,如果用户的级别为15,远程登录之后可以直接进入特权模式下
R1(config)#username admin privilege 15 password admin
R1(config)#line vty 0 4
R1(config-line)#login local
R1(config-line)#end
R1#
R1#
第二步: 对路由器R2进行预配置
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host R2
R2(config)#no ip do lo
R2(config)#line con 0
R2(config-line)#no exec-t
R2(config-line)#logg syn
R2(config-line)#int e0/0
R1(config-if)#description Connection to R1_E0/0
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
*Mar 1 00:10:09.331: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 1 00:10:10.331: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
R2(config)#username admin privilege 15 password admin
R2(config)#line vty 0 15
R2(config-line)#login local
R2(config-line)#end
*Mar 1 00:10:21.363: %SYS-5-CONFIG_I: Configured from console by console
R2#ping 12.0.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms
R2#
第三步:在R1运行动态路由协议,配置DHCP
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//配置动态路由协议,保证两个不同的网段可以相互通信
R1(config)#router rip
R1(config-router)#ver 2
R1(config-router)#no au
R1(config-router)#net 12.0.0.1
R1(config-router)#net 192.168.1.1
R1(config-router)#exit
//开启DCHP服务
R1(config)#service dhcp
R1(config)#no ip dhcp conflict logging
R1(config)#ip dhcp pool PC1_Subnet
R1(dhcp-config)#network 192.168.1.0 /24
R1(dhcp-config)#default-router 192.168.1.1
R1(dhcp-config)#domain-name cisco.com
R1(dhcp-config)#dns-server 218.30.19.40 61.134.1.4
R1(dhcp-config)#option 150 ip 192.168.1.10
R1(dhcp-config)#lease 7
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 192.168.1.1
R1(config)#ip dhcp excluded-address 192.168.1.10
R1(config)#ip dhcp pool PC2_Subnet
R1(dhcp-config)#network 172.16.1.0 /24
R1(dhcp-config)#default-router 172.16.1.1
R1(dhcp-config)#domain-name norvel.com
R1(dhcp-config)#dns-server 218.30.19.40 61.134.1.4
R1(dhcp-config)#option 150 ip 172.16.1.10
R1(dhcp-config)#lease 7
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 172.16.1.1
R1(config)#ip dhcp excluded-address 172.16.1.10
R1#show run | b ip dhcp
no ip dhcp conflict logging
ip dhcp excluded-address 192.168.1.1
ip dhcp excluded-address 192.168.1.10
ip dhcp excluded-address 172.16.1.1
ip dhcp excluded-address 172.16.1.10
ip dhcp pool PC1_Subnet
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
domain-name cisco.com
dns-server 218.30.19.40 61.134.1.4
option 150 ip 192.168.1.10
lease 7
ip dhcp pool PC2_Subnet
network 172.16.1.0 255.255.255.0
default-router 172.16.1.1
domain-name norvel.com
dns-server 218.30.19.40 61.134.1.4
option 150 ip 172.16.1.10
lease 7
R1(config)#
第四步:在R2运行动态路由协议,配置辅助地址
R1#telnet 12.0.0.2
Trying 12.0.0.2 ... Open
User Access Verification
Username: admin
Password:
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int e1/0
R2(config-if)#ip ad 172.16.1.1 255.255.255.0
R2(config-if)#no sh
R2(config-if)#router rip
R2(config-router)#ver 2
R2(config-router)#no au
R2(config-router)#net 12.0.0.2
R2(config-router)#net 172.16.1.1
R2(config-router)#exit
R2(config)#int e1/0
//配置DHCP中继地址
R2(config-if)#ip helper-address 12.0.0.1
R2(config-if)#
R1#sh ip int bri
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 12.0.0.1 YES manual up up
Serial0/0 unassigned YES unset administratively down down
Ethernet1/0 192.168.1.1 YES manual up up
Serial1/0 unassigned YES unset administratively down down
第五步:在PC1PC2上查看获得IP地址信息
开始-运行-cmd-ipconfig /all
如图: PC2
p_w_picpath
如图:PC1
p_w_picpath
第六步:查看交换机IP地址池和动态绑定信息
R1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
172.16.1.2 0100.8045.2984.f2 Mar 08 1993 12:52 AM Automatic
192.168.1.2 0100.16d3.249f.fd Mar 08 1993 12:51 AM Automatic
R1#
R1#show ip dhcp pool
Pool PC1_Subnet :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses 254
Leased addresses 1
Pending event none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
192.168.1.3 192.168.1.1 - 192.168.1.254 1
Pool PC2_Subnet :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 1
Pending event : none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
172.16.1.3 172.16.1.1 - 172.16.1.254 1
R1#
R1#sh ip ro
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
R 172.16.1.0 [120/1] via 12.0.0.2, 00:00:24, Ethernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Ethernet0/0
C 192.168.1.0/24 is directly connected, Ethernet1/0
R1#debug ip dhcp server events
R1#
*Mar 1 01:12:33.367: DHCPD: assigned IP address 172.16.1.2 to client 0100.8045.2984.f2.
R1#telnet 12.0.0.2
Trying 12.0.0.2 ... Open
User Access Verification
Username: admin
Password:
R2#sh run int e1/0
interface Ethernet1/0
ip address 172.16.1.1 255.255.255.0
ip helper-address 12.0.0.1
half-duplex
第七步:测试全网互联互通
C:\ping 172.16.1.1
Pinging 172.16.1.1 with 32 bytes of data:
Reply from 172.16.1.1: bytes=32 time=2ms TTL=255
Reply from 172.16.1.1: bytes=32 time=2ms TTL=255
Ping statistics for 172.16.1.1:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
Control-C
^C
C:\ping 12.0.0.2
Pinging 12.0.0.2 with 32 bytes of data:
Reply from 12.0.0.2: bytes=32 time=2ms TTL=255
Ping statistics for 12.0.0.2:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
Control-C
^C
C:\ping 12.0.0.1
Pinging 12.0.0.1 with 32 bytes of data:
Reply from 12.0.0.1: bytes=32 time=2ms TTL=254
Reply from 12.0.0.1: bytes=32 time=2ms TTL=254
Ping statistics for 12.0.0.1:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
Control-C
^C
C:\ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=3ms TTL=254
Ping statistics for 192.168.1.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 3ms, Average = 3ms
Control-C
^C
C:\ping 192.168.1.2
Pinging 192.168.1.2 with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time=5ms TTL=126
Ping statistics for 192.168.1.2:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 5ms, Maximum = 5ms, Average = 5ms
Control-C
^C