CCNP-28 DHCP 1(BSCI)

CCNP-28 DHCP 1

实验拓扑:

试验要求: R1 配置为 DHCP SERVER R2 配置为 DHCP CLIENT ,使 R2 能够获得 R1 分配的 IP 与其他参数。
试验目的:掌握基本的 CISCO IOS DHCP SERVER DHCP CLIENT 配置。

实验配置:
R1
DHCPSERVER(config)#service dhcp // 开启 DHCP 服务
DHCPSERVER(config)#ip dhcp pool ccnp // 定义 DHCP 地址池名字为 ccnp
DHCPSERVER(dhcp-config)#network 199.99.1.0 255.255.255.0 // 定义 dhcp 分配地址范围为 199.99.1.0/24 网段的 ip 地址
DHCPSERVER(dhcp-config)#dns-server 202.102.224.68 202.102.240.65 // 定义 DHCP SERVER 分配给 CLIENT DNS 服务器地址,最少为一个,最多可以支持 8 个。
DHCPSERVER(dhcp-config)#default-router 199.99.1.1 // 定义默认网关
DHCPSERVER(dhcp-config)#exit
DHCPSERVER(config)#ip dhcp excluded-address 199.99.1.200 199.99.1.254 // 定义 DHCP SERVER 在分配地址的时候 199.99.1.200-199.99.1.254 的地址不被分配出去
DHCPSERVER(config)#int f0/0
DHCPSERVER(config-if)#ip add 199.99.1.1 255.255.255.0
DHCPSERVER(config-if)#no shu
DHCPSERVER(config-if)#end
 
R2
DHCPCLIENT(config)#int f0/0
DHCPCLIENT(config-if)#ip address dhcp // 使接口用 DHCP 方式获取 IP
DHCPCLIENT(config-if)#no shu
 
配置完后, R2 会提示:
*Mar  1 00:04:35.599: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 199.99.1.2, mask 255.255.255.0, hostname DHCPCLIENT
表示接口 F0/0 通过 DHCP 获得的 IP 地址是 199.99.1.2/24
下面我们在 R2 show ip int br 验证一下:
DHCPCLIENT#show ip int br
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            199.99.1.2      YES DHCP   up                    up     
确实得到了这个 ip 地址。
我们再到 R1 上查看一下 DHCP SERVER 信息:
DHCPSERVER#show ip dhcp server statistics
Memory usage         23708
Address pools        1 // 地址池数量 1
Database agents      0
Automatic bindings   1// 自动获得的数量 1
Manual bindings      0
Expired bindings     0
Malformed messages   0
Secure arp entries   0
 
Message              Received
BOOTREQUEST          0
DHCPDISCOVER         1// 收到 1 DHCPDISCOVER 报文
DHCPREQUEST          1// 收到 1 DHCPREQUEST 报文
DHCPDECLINE          0
DHCPRELEASE          0
DHCPINFORM           0
 
Message              Sent
BOOTREPLY            0
DHCPOFFER            1// 发送一个 DHCPOFFER 报文
DHCPACK              1// 发送一个 DHCPACK 报文
DHCPNAK              0
上面的输出完全符合 DHCP 分配 IP 地址的四次握手的规则:

下面我们分别在 R1 R2 debug 一下,观察一下 DHCP 的工作过程,首先在 R1 debug ip dhcp server packet , 再在 R2 debug dhcp ,然后把 R2 F0/0 端口 shut no shut ,观察调试信息:
DHCPSERVER#debug ip dhcp server packet
DHCPSERVER#
*Mar  1 00:10:34.103: DHCPD: DHCPRELEASE message received from client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30 (199.99.1.3). // 收到 199.99.1.3 释放 IP 地址的消息。
*Mar  1 00:10:36.079: DHCPD: DHCPRELEASE message received from client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30 (199.99.1.3).
*Mar  1 00:10:36.083: DHCPD: Finding a relay for client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30 on interface FastEthernet0/0.// 在接口 F0/0 寻找中继。
*Mar  1 00:10:46.459: DHCPD: DHCPDISCOVER received from client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30 on interface FastEthernet0/0. // 在接口 F0/0/ 收到 0063.6973….. 发来的 DHCPDISCOVER 消息。
*Mar  1 00:10:46.459: DHCPD: Allocate an address without class information (199.99.1.0) // 分配一个地址。
*Mar  1 00:10:48.459: DHCPD: Sending DHCPOFFER to client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30 (199.99.1.4).// 发送 DHCPOFFER 消息给客户端,包含分配给它的 IP 地址为 199.99.1.4
*Mar  1 00:10:48.459: DHCPD: broadcasting BOOTREPLY to client cc00.0978.0000.// 广播 BOOTREPLY cc00.0978.0000 客户。
*Mar  1 00:10:48.599: DHCPD: DHCPREQUEST received from client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30.// 收到客户端发来的 DHCPREQUEST 报文。
*Mar  1 00:10:48.603: DHCPD: No default domain to append - abort update
*Mar  1 00:10:48.603: DHCPD: Sending DHCPACK to client 0063. 6973.636f .2d63.6330.302e.3039.3738.2e30.3030.302d. 4661.302f .30 (199.99.1.4).// 发送 DHCPACK 给客户端用来确认。
*Mar  1 00:10:48.603: DHCPD: broadcasting BOOTREPLY to client cc00.0978.0000.
 
再到 R2 上查看一下调试信息:
DHCPCLIENT#debug dhcp
DHCP client activity debugging is on
DHCPCLIENT(config-if)#no shu
DHCPCLIENT#
*Mar  1 00:09:05.407: DHCP: DHCP client process started: 10// 启动 dhcp 进程 10
*Mar  1 00:09:05.423: RAC: Starting DHCP discover on FastEthernet0/0// 在接口 F0/0 发送 DHCP discover 报文
*Mar  1 00:09:05.423: DHCP: Try 1 to acquire address for FastEthernet0/0// 第一次尝试获取 IP 地址
*Mar  1 00:09:05.435: DHCP: allocate request// 分配请求
*Mar  1 00:09:05.435: DHCP: zapping entry in DHC_PURGING state for Fa0/0
*Mar  1 00:09:05.435: DHCP: deleting entry 6407D740 199.99.1.3 from list
*Mar  1 00:09:05.439: DHCP: new entry. add to queue, interface FastEthernet0/0
*Mar  1 00:09:05.439: DHCP: SDiscover attempt # 1 for entry:// Discover 报文的一些参数
*Mar  1 00:09:05.439: DHCP: SDiscover: sending 299 byte length DHCP packet
*Mar  1 00:09:05.439: DHCP: SDiscover 299 bytes
*Mar  1 00:09:05.443:             B'cast on FastEthernet0/0 interface from 0.0.0 .0
*Mar  1 00:09:07.403: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:09:07.751: DHCP: Received a BOOTREP pkt
*Mar  1 00:09:07.751: DHCP: offer received from 199.99.1.1// 收到 199.99.1.1 offer 消息
*Mar  1 00:09:07.755: DHCP: SRequest attempt # 1 for entry:// Request 报文的一些参数
*Mar  1 00:09:07.755: DHCP: SRequest- Server ID option: 199.99.1.1
*Mar  1 00:09:07.755: DHCP: SRequest- Requested IP addr option: 199.99.1.4
*Mar  1 00:09:07.755: DHCP: SRequest placed lease len option: 86400
*Mar  1 00:09:07.755: DHCP: SRequest: 317 bytes
*Mar  1 00:09:07.755: DHCP: SRequest: 317 bytes
*Mar  1 00:09:07.759:             B'cast on FastEthernet0/0 interface from 0.0.0 .0
*Mar  1 00:09:07.903: DHCP: Received a BOOTREP pkt
*Mar  1 00:09:08.403: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
*Mar  1 00:09:11.919: DHCP Client Pooling: ***Allocated IP address: 199.99.1.4// 获取 199.99.1.4 这个 IP 地址。
*Mar  1 00:09:11.995: Allocated IP address = 199.99.1.4  255.255.255.0// 被分配的 IP 地址为 199.99.1.4 ,掩码为 255.255.255.0
R2 上用 show 命令查看 DHCP 的一些信息:
DHCPCLIENT#show dhcp server
   DHCP server: ANY (255.255.255.255)
    Leases:   3
    Offers:   3      Requests: 3     Acks : 3     Naks: 0
    Declines: 0      Releases: 6     Query: 0     Bad: 0
    DNS0:   202.102.224.68,   DNS1:  202.102.240.65
Subnet: 255.255.255.0
 
DHCPCLIENT#show dhcp lease
Temp IP addr: 199.99.1.4  for peer on Interface: FastEthernet0/0
Temp  sub net mask: 255.255.255.0
   DHCP Lease server: 199.99.1.1, state: 3 Bound
   DHCP transaction id: FC9
   Lease: 86400 secs,  Renewal: 43200 secs,  Rebind: 75600 secs
Temp default-gateway addr: 199.99.1.1
   Next timer fires after: 11:58:09
   Retry count: 0   Client-ID: cisco-cc00.0978.0000-Fa0/0
   Client-ID hex dump: 636973636F 2D636330302E303937382E
                       303030302D 4661302F 30
   Hostname: DHCPCLIENT
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*   0.0.0 .0/0 [254/0] via 199.99.1.1
 
从上面的输出可以看到 DHCP 分配给它的 DNS 和默认网关,还有 DHCP SERVER 的一些信息。
 
实验总结:掌握基本的 DHCP SERVER DHCP CLIENT 的配置

你可能感兴趣的:(职场,休闲,ccnp)