CCIE思科教育培训 CCIE培训

DHCP和DHCP中继实验及研究


1.1组网需求
 

随着网络的扩大,网络的信息点不断增加,手动配置和维护IP地址带来大量的管理和维护的负担,并且经常出现地址冲突,为了减轻网络的维护负担则出现了一种新的技术——DHCP
 

1.2组网拓扑


 


1.3实验目标
 

①熟悉层次化配制方法

②实现局域网内需要自动获取地址的PC能通过DHCP服务器获取IP DNS

③分析PCDHCP服务器获取IP地址的过程

④分析PC通过中继设备从服务器获取IP地址的过程 www.it165.net

⑤了解为什么使用排除地址

⑥了解dhcp各种报文的格式
 

1.4实验步骤
 

14.1 基本配置
 

R7(config)#no ip domain-lookup

R7(config)#line console 0

R7(config-line)# logging synchronous

R7(config-line)# exec-timeout 0 0

R7(config-line)# no login

R7(config-line)#

R7(config-line)#line vty 0 4

R7(config-line)# no login

 

 

 

 

1.4.2二层链路及vlan配置和调试

 

 

1.4.3三层接口配置和调试
 

R7做成单臂路由

R7(config-subif)#int f0/0.10

R7(config-subif)#en do 10

R7(config-subif)#ip add 192.168.10.1 255.255.255.0

R7(dhcp-config)#default-router 192.168.10.1

R7(dhcp-config)#dns-server 59.51.78.211

R7(config)#ip dhcp excluded-address 192.168.10.1

 

R7(config-subif)#int f0/0.20

R7(config-subif)#en do 20

R7(config-subif)#ip add 192.168.20.1 255.255.255.0

R7(config-subif)#no shut

R7(dhcp-config)#default-router 192.168.20.1

R7(dhcp-config)#dns-server 59.51.78.211

R7(config)#ip dhcp excluded-address 192.168.20.1

 

 

1.4.5 DHCP客户端

使用路由器模拟PC机作为dhcp客户端

R6(config)#int f0/0

R6(config-if)#ip add dhcp

R6(config-if)#no shut

R6(config-if)#exit

R6(config)#no ip routing

 

Router(config)#int e 0

Router(config-if)#ip add dhcp

Router(config-if)#no shut  

Router(config-if)#exit

Router(config)#no ip routing

 

 

R7#debug ip dhcpserver packet

00:54:04.055: DHCPD: DHCPDISCOVER received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 on interface FastEthernet0/0.10.

00:54:06.055: DHCPD: Sending DHCPOFFER to client

0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 (192.168.10.2).

0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 (192.168.10.2).

00:54:06.055: DHCPD: broadcasting BOOTREPLY to client 000d.28f1.0160.

00:54:06.059: DHCPD: DHCPREQUEST received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30.

00:54:06.059: DHCPD: Sending DHCPACK to client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 (192.168.10.2).

00:54:06.059: DHCPD: broadcasting BOOTREPLY to client 000d.28f1.0160.

 

 

1.4.6全网连通性测试
 

R6#ping 192.168.20.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.20.2, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 4/4/4 ms

r8#ping 192.168.10.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.10.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms

 

 

 

在配置完成之后没有debug信息后来发现没有在sw13上划分vlan 划过之后 r6不能自动获取ip地址 show ip int b 后发现

R6#show ip int b

Interface                  IP-Address      OK? Method Status                Protocol

FastEthernet0/0            unassigned      YES manual up                   up     

FastEthernet0/1            unassigned      YES unset administratively down down   

Serial1/0                  unassigned      YES unset administratively down down   

Serial1/1                  unassigned      YES unset administratively down down   

Serial1/2                  unassigned      YES unset administratively down down   

 

Manual 为手动  所以要为r6配置dhcp 配置后成功获取ip地址

 

 

1.5DHCP中继

 

拓扑图


 


Dhcp中继是当dhcp服务器与dhcp客户端不在同一广播域时,需要使用dhcp中继技术让中间的三层设备为其中继转发dhcp报文

 

 

清楚之前的实验dhcp配置

R7(config)#no ip dhcp pool vlan10

R7(config)#no ip dhcp pool vlan20

R7(config)#no ip dhcp excluded-address 192.168.10.1

R7(config)#no ip dhcp excluded-address 192.168.20.1

 

 

三层接口配置和调试

R4(config)#int e0/1

R4(config-if)#ip add 192.168.1.1 255.255.255.0

R4(config-if)#no shut

R4(config-if)#end

 

R7(config)#int f0/1

R7(config-if)#ip add 192.168.1.2 255.255.255.0

R7(config-if)#no shut

R7(config-if)#end

 

R4#ping 192.168.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 1/2/4 ms

 

R7#show ip int b

Interface              IP-Address     OK? Method Status              Protocol

FastEthernet0/0           unassigned      YES unset up                    up     

FastEthernet0/0.10         192.168.10.1    YES manual up                    up     

FastEthernet0/0.11       unassigned      YES manual deleted               down   

FastEthernet0/0.20         192.168.20.1    YES manual up                    up     

FastEthernet0/0.21       unassigned      YES manual deleted               down   

FastEthernet0/1            192.168.1.2     YES manual up                    up     

 

Dhcp服务器配置

R4(config)#ip dhcp pool vlan10

R4(dhcp-config)#network 192.168.10.0 255.255.255.0

R4(dhcp-config)#default-router 192.168.10.1

R4(dhcp-config)#dns-server 59.51.78.211

R4(dhcp-config)#exit

R4(config)#ip dhcp excluded-address 192.168.10.1

R4(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.2

R4#show ip route

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

 

S    192.168.10.0/24 [1/0] via 192.168.1.2

C    192.168.1.0/24 is directly connected, Ethernet0/1

 

R4#ping 192.168.10.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

中继设备配置

R7(config)#int f0/0.10

R7(config-subif)#ip helper-add

R7(config-subif)#ip helper-address 192.168.1.1

R7(config-subif)#end

Pcdhcp获取ip地址

6(config)#int f0/0

R6(config-if)#ip add dhcp

R6(config-if)#no shut

03:20:21.075: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 192.168.10.2, mask 255.255.255.0, host

 

R6#show ip int b

Interface             IP-Address    OK? Method Status          Protocol

FastEthernet0/0      192.168.10.2    YES    uP   up                up     

 

 

 

R4#debug ip dhcp server packet

R4#

03:27:01.345: DHCPD: DHCPRELEASE message received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30

03:27:01.345: DHCPD: 192.168.10.1 is not a local address.

03:27:01.405: DHCPD: DHCPRELEASE message received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30

03:27:01.405: DHCPD: 192.168.10.1 is not a local address.

03:27:02.343: DHCPD: DHCPRELEASE message received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30

03:27:02.343: DHCPD: 192.168.10.1 is not a local address.

03:27:03.421: DHCPD: DHCPDISCOVER received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 through relay 192.168.10.1.

03:27:05.424: DHCPD: Sending DHCPOFFER to client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 (192.168.10.2).

03:27:05.424: DHCPD: unicasting BOOTREPLY for client 000d.28f1.0160 to relay 192.168.10.1.//单路广播

03:27:05.436: DHCPD: DHCPREQUEST received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30.

03:27:05.436: DHCPD: Sending DHCPACK to client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30 (192.168.10.2).

03:27:05.436: DHCPD: unicasting BOOTREPLY for client 000d.28f1.0160 to relay 192.168.10.1.//单路广播

R4# undebug all

All possible debugging has been turned off

本文出自 “网络技术” 博客


 


Tags:

发布: admin 分类: CCIE思科 评论: 0 浏览: 99
留言列表
发表留言
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。