DHCP
和
DHCP
中继
1.1
组网需求
随着网络的扩大,网络的信息点不断增加,手动配置和维护 IP
地址带来大量的管理和维护的负担,并且经常出现地址冲突,为了减轻网络的维护负担则出现了一种新的技术 ——DHCP
1.2
组网拓扑
1.3
实验目标
①熟悉层次化配制方法
②实现局域网内需要自动获取地址的 PC
能通过 DHCP
服务器获取 IP
和 DNS
③分析 PC
从 DHCP
服务器获取 IP
地址的过程
④分析 PC
通过中继设备从服务器获取 IP
地址的过程
⑤了解为什么使用排除地址
⑥了解 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: DHCP
DISCOVER 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 DHCP
OFFER 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: DHCP
REQUEST received from client 0063.6973.636f.2d30.3030.642e.3238.6631.2e30.3136.302d.4661.302f.30.
00:54:06.059: DHCPD: Sending DHCP
ACK 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 BOOT
REPLY 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
Pc
机 dhcp
获取 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