CCNP-29 DHCP 2
实验拓扑:
实验要求:
R1
配置为
DHCP SERVER
,
R2
配置为
DHCP
中继代理,
R3
配置为
DHCP CLIENT
。
试验目的:掌握路由器
DHCP helper-addresss
的配置方法。
实验配置:
R1
:
DHCPSERVER(config)#service dhcp
DHCPSERVER(config)#ip dhcp pool ccnp
DHCPSERVER(dhcp-config)#network 199.99.1.0 255.255.255.0
DHCPSERVER(dhcp-config)#default-router 199.99.1.1
DHCPSERVER(dhcp-config)#dns-server 199.99.1.253 199.99.1.254
DHCPSERVER(dhcp-config)#domain-name cisco.com
DHCPSERVER(dhcp-config)#lease 2
DHCPSERVER(dhcp-config)#exit
DHCPSERVER(config)#ip dhcp excluded-address 199.99.1.250 199.99.1.254
DHCPSERVER(config)#int f0/0
DHCPSERVER(config-if)#ip add
10.1.1
.1 255.255.255.0
DHCPSERVER(config-if)#no shu
DHCPSERVER(config-if)#exit
DHCPSERVER(config)#ip route
0.0.0
.0 0.0.0.0 10.1.1.2
DHCPSERVER(config)#end
R2
:
DHCPRELAYAGENT(config)#int f0/0
DHCPRELAYAGENT(config-if)#ip add
10.1.1
.2 255.255.255.0
DHCPRELAYAGENT(config-if)#no shu
DHCPRELAYAGENT(config-if)#exit
DHCPRELAYAGENT(config)#int f1/0
DHCPRELAYAGENT(config-if)#ip add 199.99.1.1 255.255.255.0
DHCPRELAYAGENT(config-if)#ip helper-address
10.1.1
.1 //
设置
helper-address
为
DHCP SERVER
的地址。
DHCPRELAYAGENT(config-if)#no shu
DHCPRELAYAGENT(config-if)#exit
DHCPRELAYAGENT(config)#ip forward-protocol udp bootpc//
允许
bootpc
(
68
)通过
DHCPRELAYAGENT(config)#ip forward-protocol udp bootps//
允许
bootpc
(
67
)通过
DHCPRELAYAGENT(config)#ip route
0.0.0
.0 0.0.
0.0 f
0/0
DHCPRELAYAGENT(config)#end
R3
:
DHCPCLIENT(config)#int f0/0
DHCPCLIENT(config-if)#ip add dhcp
DHCPCLIENT(config-if)#no shu
上面的是基本的配置,因为在接口设置完
ip helper-address
后,接口会转发所有的广播数据包,所以我们可以配置
ip forward-protocol
来控制转发广播包的类型,配置完成后我们看看
R3
的
F0/0
接口能不能获得正确的
IP
地址:
DHCPCLIENT#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 199.99.1.2 YES DHCP up up
OK
,得到了
199.99.1.2
这个
IP
地址,接下来我们在
R2
上开启
debug ip dhcp server packet
,然后再回到
R3
的
F0/0
接口,把它
shut
,再
no shut
,观察
R2
上出现的
debug
信息:
DHCPRELAYAGENT#debug ip dhcp server packet
DHCPRELAYAGENT#
*Mar 1 00:10:57.603: IP: s=
0.0.0
.0 (FastEthernet1/0), d=255.255.255.255, len 604, rcvd 2
*Mar 1 00:10:57.607: DHCPD: setting giaddr to 199.99.1.1.
*Mar 1 00:10:57.607: IP: tableid=0, s=199.99.1.1 (local), d=
10.1.1
.1 (FastEthernet0/0), routed via FIB
*Mar 1 00:10:57.607: IP: s=199.99.1.1 (local), d=
10.1.1
.1 (FastEthernet0/0), len 604, sending
*Mar 1 00:10:57.611: DHCPD: BOOTREQUEST from 0063.
6973.636f
.2d63.6330.302e.3064.3034.2e30.3030.302d.
4661.302f
.30 forwarded to
10.1.1
.1.
*Mar 1 00:10:57.831: IP: tableid=0, s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.3 (FastEthernet1/0), routed via RIB
*Mar 1 00:10:57.831: IP: s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.3 (FastEthernet1/0), g=199.99.1.3, len 56, forward
*Mar 1 00:10:57.835: IP: s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.3 (FastEthernet1/0), len 56, encapsulation failed //
不知道为什么会出现封装错误的提示。
*Mar 1 00:10:59.751: IP: tableid=0, s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.1 (FastEthernet1/0), routed via RIB
*Mar 1 00:10:59.751: IP: s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.1, len 329, rcvd 4
*Mar 1 00:10:59.755: DHCPD: forwarding BOOTREPLY to client cc00.0d04.0000.
*Mar 1 00:10:59.755: DHCPD: broadcasting BOOTREPLY to client cc00.0d04.0000.
*Mar 1 00:10:59.759: IP: s=199.99.1.1 (local), d=255.255.255.255 (FastEthernet1/0), len 329, sending broad/multicast
*Mar 1 00:10:59.939: IP: s=
0.0.0
.0 (FastEthernet1/0), d=255.255.255.255, len 604, rcvd 2 //
在接口
F1/0
收到广播包。
*Mar 1 00:10:59.943: DHCPD: Finding a relay for client 0063.
6973.636f
.2d63.6330.302e.3064.3034.2e30.3030.302d.
4661.302f
.30 on interface FastEthernet1/0.//
在接口
F1/0
寻找中继
*Mar 1 00:10:59.943: DHCPD: setting giaddr to 199.99.1.1.//
寻找到中继接口
199.99.1.1
(自己的理解)
*Mar 1 00:10:59.943: IP: tableid=0, s=199.99.1.1 (local), d=
10.1.1
.1 (FastEthernet0/0), routed via FIB //
把原地址设置为自己,目的地址为
DHCP SERVER
,根据转发信息表
(FIB)
转发。
*Mar 1 00:10:59.947: IP: s=199.99.1.1 (local), d=
10.1.1
.1 (FastEthernet0/0), len 604, sending
*Mar 1 00:10:59.947: DHCPD: BOOTREQUEST from 0063.
6973.636f
.2d63.6330.302e.3064.3034.2e30.3030.302d.
4661.302f
.30 forwarded to
10.1.1
.1.
*Mar 1 00:11:00.131: IP: tableid=0, s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.1 (FastEthernet1/0), routed via RIB//
收到
DHCP SERVER
的单播数据包。
*Mar 1 00:11:00.131: IP: s=
10.1.1
.1 (FastEthernet0/0), d=199.99.1.1, len 352, rcvd 4
*Mar 1 00:11:00.135: DHCPD: forwarding BOOTREPLY to client cc00.0d04.0000.//
转发
BOOTREPLY
给
cc00.0d04.0000
。
*Mar 1 00:11:00.135: DHCPD: broadcasting BOOTREPLY to client cc00.0d04.0000.//
广播
BOOTREPLY
给
cc00.0d04.0000
。
*Mar 1 00:11:00.139: IP: s=199.99.1.1 (local), d=255.255.255.255 (FastEthernet1/0), len 352, sending broad/multicast//
向局域网内广播。
从上面的信息可以知道
R2
把
R3
发送来的广播包转变为单播数据包发送给
R1
,把
R1
发来的单播数据包转变为广播包在局域网内广播。
然后我们再到
R3
上查看一下:
DHCPCLIENT#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 199.99.1.3 YES DHCP up up
得到了
IP 199.99.1.3
。
DHCPCLIENT#show dhcp server
DHCP server: ANY (255.255.255.255)
Leases: 2
Offers: 2 Requests: 2 Acks : 2 Naks: 0
Declines: 0 Releases: 3 Query: 0 Bad: 0
DNS0: 199.99.1.253, DNS1: 199.99.1.254
Subnet: 255.255.255.0 DNS Domain: cisco.com
DHCPCLIENT#
*Mar 1 00:12:16.211:
-----Additional Debug------
*Mar 1 00:12:16.211: DHCP process ID 61 status 10
*Mar 1 00:12:16.211: DHCP Network Discovery is disabled
*Mar 1 00:12:16.211: DHCP NetDiscovery Informs 0 Discovers 0 Period 0
DHCPCLIENT#
DHCPCLIENT#show dhcp lease
Temp IP addr: 199.99.1.3 for peer on Interface: FastEthernet0/0
Temp sub net mask: 255.255.255.0
DHCP Lease server:
10.1.1
.1, state: 3 Bound
DHCP transaction id:
105F
Lease: 172800 secs, Renewal: 86400 secs, Rebind: 151200 secs
Temp default-gateway addr: 199.99.1.1
Next timer fires after: 23:58:03
Retry count: 0 Client-ID: cisco-cc00.0d04.0000-Fa0/0
Client-ID hex dump:
636973636F
2D636330302E306430342E
303030302D
4661302F
30
Hostname: DHCPCLIENT
也得到了
DNS
和
DNS Domain
的信息,租期为
2
天(
172800 secs
)。
DHCPCLIENT#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 199.99.1.1 to network
0.0.0
.0
C 199.99.1.0/24 is directly connected, FastEthernet0/0
S
10.1.1
.1 [254/0] via 199.99.1.1, FastEthernet0/0
S*
0.0.0
.0/0 [254/0] via 199.99.1.1
还得到了默认网关的信息,还有一条到
DHCP SERVER
的静态路由。
实验总结:掌握基本的路由器
DHCP helper-address
的配置方法。
本文转自loveme2351CTO博客,原文链接:
http://blog.51cto.com/loveme23/51136
,如需转载请自行联系原作者