CCNP-30 DHCP 3
实验拓扑:
实验要求:把
R1
配置为
DHCP SERVER
,把
SW
配置为
DHCP RELAY AGENT
,把
R2
配置为
DHCP CLIENT
。
试验目的:掌握交换机
DHCP
中继代理的配置方法。
试验配置:
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)#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 199.99.1.250 255.255.255.0
DHCPSERVER(config-if)#no shu
DHCPSERVER(config-if)#exit
SW
:
SW(config)#service dhcp //
开启交换机的
DHCP
服务
SW(config)#ip dhcp relay information option //
开启
DHCP
中继代理
option82
选项
SW(config)#exit
SW#vlan database
SW(vlan)#vlan 10
SW(vlan)#exit
SW#config t
SW(config)#int range f0/0 - 15
SW(config-if-range)#switchport access vlan 10
SW(config-if-range)#exit
SW(config)#int vlan 10
SW(config-if)#ip add 199.99.1.1 255.255.255.0
SW(config-if)#ip helper-address 199.99.1.250
SW(config-if)#ip dhcp relay information trusted //
配置
DHCP
中继代理信任选项
SW(config-if)#exit
R2
:
DHCPCLIENT(config)#int f0/0
DHCPCLIENT(config-if)#ip add dhcp
DHCPCLIENT(config-if)#no shu
按照上面的配置完成后,在
R2
上
show ip int br
查看一下接口是否得到了
IP
地址:
DHCPCLIENT#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 199.99.1.2 YES DHCP up up
好的,正确得到了
IP
地址,下面我们在
SW
上开启
debug ip dhcp server packet
,再到
R2
把
F0/0
接口
shut
再
no shut
一下,观察
SW
上的调试信息:
SW#debug ip dhcp server packet
SW#
*Mar 1 00:10:56.575: DHCPD: setting giaddr to 199.99.1.1.
*Mar 1 00:10:56.579: DHCPD: adding relay information option.//
加入
option82
选项
*Mar 1 00:10:56.579: DHCPD: BOOTREQUEST from 0063. 6973.636f .2d63.6330.302e.3066.3334.2e30.3030.302d. 4661.302f .30 forwarded to 199.99.1.250.
*Mar 1 00:10:58.675: DHCPD: forwarding BOOTREPLY to client cc 00.0f 34.0000.
*Mar 1 00:10:58.675: DHCPD: validating relay information option.//
通过
option82
选项
*Mar 1 00:10:58.675: DHCPD: broadcasting BOOTREPLY to client cc 00.0f 34.0000.
*Mar 1 00:10:58.679: DHCPD: Finding a relay for client 0063. 6973.636f .2d63.6330.302e.3066.3334.2e30.3030.302d. 4661.302f .30 on interface Vlan10.
*Mar 1 00:10:58.679: DHCPD: setting giaddr to 199.99.1.1.
*Mar 1 00:10:58.679: DHCPD: adding relay information option. //
加入
option82
选项
*Mar 1 00:10:58.683: DHCPD: BOOTREQUEST from 0063. 6973.636f .2d63.6330.302e.3066.3334.2e30.3030.302d. 4661.302f .30 forwarded to 199.99.1.250.
*Mar 1 00:10:58.995: DHCPD: forwarding BOOTREPLY to client cc 00.0f 34.0000.
*Mar 1 00:10:58.995: DHCPD: validating relay information option. //
通过
option82
选项
*Mar 1 00:10:58.995: DHCPD: broadcasting BOOTREPLY to client cc 00.0f 34.0000.
上面用红颜色标记的部分就是有关中继代理
option82
选项的信息,
option82
选项是用来验证
DHCP
信息的准确性的,有关
option82
选项的详细信息,请参照
RFC3046
。然后在
SW
上
show ip dhcp relay information trusted-sources
:
SW#show ip dhcp relay information trusted-sources
List of trusted sources of relay agent information option:
Vlan10
然后我们再回到
R2
上察看几个
show
命令:
DHCPCLIENT#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 199.99.1.3 YES DHCP up up
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: 199.99.1.250, state: 3 Bound
DHCP transaction id: 186E
Lease: 86400 secs, Renewal: 43200 secs, Rebind: 75600 secs
Temp default-gateway addr: 199.99.1.1
Next timer fires after: 11:59:34
Retry count: 0 Client-ID: cisco-cc 00.0f 34.0000-Fa0/0
Client-ID hex dump: 636973636F 2D636330302E306633342E
303030302D 4661302F 30
Hostname: DHCPCLIENT
DHCPCLIENT#show dhcp server
DHCP server: ANY (255.255.255.255)
Leases: 2
Offers: 5 Requests: 2 Acks : 4 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#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 SERVER
分配给它的信息,在
R1
上
show ip dhcp binding
:
DHCPSERVER#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
199.99.1.3 0063. 6973.636f .2d63. Mar 02 2002 12:11 AM Automatic
6330.302e.3066.3334.
2e30.3030.302d.4661.
302f .30
注意用红颜色标记的部分并不是
R2
的
F0/0
接口的
MAC
地址,它是
Client-ID
,用来识别某个接口的。
实验总结:掌握基本的交换机
DHCP
中继代理的配置方法。