2019-11-28 NCS XR 配置DHCP Relay和DHCP Server

在NCS上配DHCP Relay和DHCP Server,先说Server吧
1、配置本机的IP pool

#configure
(config)#pool vrf default ipv4 Pool_1
#/* Configures an IPv4 pool for the specifed VRF or all VRFs. Use the 'ipv6' keyword for IPv6 pool. */
(config-pool-ipv4)# address-range 10.111.1.3 10.111.1.254
#/*Specifies ip address range for allocation. */
(config-pool-ipv4)#network 10.111.1.0 
#/* Specifies network for allocation. */ 
上面两条配置任意一条

2、配置DHCP Server Profile

#configure
router(config)#dhcp ipv4
/* The 'dhcp ipv6' command configures DHCP for IPv6 and enters the DHCPv6 configuration submode. */
router(config-dhcpv4)#profile ISP_1 server
/* Enters the server profile configuration mode. */
router(config-dhcpv4-server-profile)# lease 0 0 5
router(config-dhcpv4-server-profile)# pool Pool_1
#/* Configures the DAPS pool name. */
router(config-dhcpv4-server-profile)#dns-server 8.8.8.8 8.8.4.4
#或者DNS域名
router(config-dhcpv4-server-profile)domain-name xxx.com
router(config-dhcpv4-server-profile)subnet-mask 255.255.255.0
router(config-dhcpv4-server-profile)default-router 10.111.1.1
router(config-dhcpv4-server-profile)#class ISP1_CLASS 
#/* Creates and enters the server profile class. */
router(config-dhcpv4-server-profile-class)#pool ISP1_CLASS_POOL 
#/* Configures the pool name. */
router(config-dhcpv4-server-profile-class)#match option 60 hex PXEClient_2
#/* DHCP server selects a pool from a class by matching options in the received DISCOVER packet with the match option. */
router(config-dhcpv4-server-profile-class)#exit
router(config-dhcpv4-server-profile)#exit 
router(config-dhcpv4)#commit

3、绑定端口

Router(config)# dhcp ipv4
Router(config-dhcpv4)#interface Te0/0/0/0 server profile ISP_1 server

4、校验

RP/0/RP0/CPU0:ncs01#sh dhcp ipv4 server statistics detail
Thu Nov 28 15:43:40.194 UTC

DHCP IPv4 Proxy/Server Statistics for VRF default:

     TYPE         |    RECEIVE    |    TRANSMIT   |     DROP      |
-------------------------------------------------------------------
 DISCOVER         |         7507  |            0  |         7139  |
 OFFER            |            0  |          303  |            0  |
 REQUEST          |       100707  |            0  |        87920  |
 DECLINE          |            0  |            0  |            0  |
 ACK              |            0  |        12787  |            0  |
 NAK              |            0  |            0  |            0  |
 RELEASE          |            3  |            0  |            0  |
 INFORM           |            0  |            0  |            0  |
 LEASEQUERY       |            0  |            0  |            0  |
 LEASEUNASSIGNED  |            0  |            0  |            0  |
 LEASEUNKNOWN     |            0  |            0  |            0  |
 LEASEACTIVE      |            0  |            0  |            0  |
 BOOTP-REQUEST    |            0  |            0  |            0  |
 BOOTP-REPLY      |            0  |            0  |            0  |

再说DHCP Relay
1、创建Relay Profile

Router(config)# dhcp ipv4
#/* Configures DHCP for IPv4 and enters the DHCPv4 configuration submode. */
Router(config-dhcpv4)# profile r1 relay 
#/* Enables DHCP relay profile */
Router(config-dhcpv4-relay-profile)# helper-address vrf A 10.10.10.1 giaddr 40.1.1.2 
Router(config-dhcpv4-relay-profile)# broadcast-flag policy check
#/* Configures VRF addresses for forwarding UDP broadcasts, including DHCP. */
Router(config-dhcpv4-relay-profile)# relay information option vpn Router(config-dhcpv4-relay-profile)# relay information option vpn-mode rfc
#/* Inserts the DHCP relay agent information option (option-82 field) in forwarded BOOTREQUEST messages to a DHCP server. */
Router(config-dhcpv4-relay-profile)# relay information option allow-untrusted 
/* (Optional) Configures the DHCP IPv4 Relay not to discard BOOTREQUEST packets that have an existing relay information option and the giaddr set to zero. */
Router(config-dhcpv4-relay-profile)# exit

2、绑定端口

Router(config-dhcpv4)# interface BVI 1 relay profile r1 
Router(config-dhcpv4)# commit
#/* Configures DHCP relay on a BVI interface and commits the configuration */

3、校验

RP/0/RP0/CPU0:ncs01#sh dhcp ipv4 relay statistics detail
Thu Nov 28 15:43:55.123 UTC

DHCP IPv4 Relay Statistics for VRF default:

     TYPE         |    RECEIVE    |    TRANSMIT   |     DROP      |
-------------------------------------------------------------------
 DISCOVER         |       432456  |       996447  |       100307  |
 OFFER            |          396  |          396  |            0  |
 REQUEST          |          422  |         1188  |           26  |
 DECLINE          |            0  |            0  |            0  |
 ACK              |          381  |          381  |            0  |
 NAK              |           14  |           14  |            0  |
 RELEASE          |            0  |            0  |            0  |
 INFORM           |            0  |            0  |            0  |
 LEASEQUERY       |            0  |            0  |            0  |
 LEASEUNASSIGNED  |            0  |            0  |            0  |
 LEASEUNKNOWN     |            0  |            0  |            0  |
 LEASEACTIVE      |            0  |            0  |            0  |
 BOOTP-REQUEST    |            0  |            0  |            0  |
 BOOTP-REPLY      |            0  |            0  |            0  |
 BOOTP-INVALID    |            0  |            0  |            0  |

在DHCP服务器(KEA)上,查看DHCP注册信息:

[axing@kea-1 kea]$ tail -f /var/kea/kea-forensic4.20191128.txt
2019-11-28 16:07:34 GMT Address: xxx.xx.xxx.94 has been renewed for 1 days 0 hrs 0 mins 0 secs to a device with hardware address: hwtype=1 30:23:03:9b:07:2a, client-id: 01:30:23:03:9b:07:2a connected via relay at address: xxx.xx.xxx.1
2019-11-28 16:07:34 GMT Address: xxx.xx.xxx.94 has been renewed for 1 days 0 hrs 0 mins 0 secs to a device with hardware address: hwtype=1 30:23:03:9b:07:2a, client-id: 01:30:23:03:9b:07:2a connected via relay at address: xxx.xx.xxx.1
2019-11-28 16:08:29 GMT Address: xxx.xx.xxx.248 has been assigned for 1 days 0 hrs 0 mins 0 secs to a device with hardware address: hwtype=1 fc:aa:14:cd:00:2f, client-id: 01:fc:aa:14:cd:00:2f connected via relay at address: xxx.xx.xxx.1, identified by circuit-id: 6f:6c:30:31:2e:77:68:69:2e:6c:6f:6e:20:78:70:6f:6e:20:30:2f:31:2f:30:2f:30:3a:31:31:2e:31:2e:31:30:31
...

Tips:
relay information option allow-untrusted
必须配置,否则会丢弃Discover包;
端口下有第二地址的时候,需要指定地址,使用giaddr
helper-address vrf A 10.10.10.1 giaddr 40.1.1.2

配置范例:

RP/0/RP0/CPU0:ncs01#sh run dhcp ipv4
Thu Nov 28 15:37:51.001 UTC
dhcp ipv4
 profile kea relay
  helper-address vrf default xx.2.11.81 giaddr xxx.xx.xxx.1
  helper-address vrf default xx.113.xx.8 giaddr xxx.xx.xxx.1
  helper-address vrf default xx.113.xx.255 giaddr xxx.xx.xxx.1
  relay information option allow-untrusted
 !
 profile Pool_23 server
  lease 0 0 5
  pool Pool_23
  dns-server 8.8.8.8 8.8.4.4
  domain-name xxx.co.uk
  subnet-mask 255.255.254.0
  default-router 10.xx.xx.1
 !
 interface Bundle-Ether5 server profile Pool_23
 interface Bundle-Ether5.101 relay profile kea
!
pool vrf default ipv4 Pool_23
 address-range 10.xxx.xx.3 10.xxx.xx.254
!
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 225,928评论 6 523
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 97,032评论 3 410
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 173,382评论 0 370
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 61,580评论 1 304
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 70,558评论 6 403
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 54,018评论 1 316
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 42,261评论 3 432
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 41,328评论 0 281
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 47,858评论 1 328
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 39,843评论 3 351
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 41,954评论 1 358
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 37,565评论 5 352
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 43,251评论 3 342
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 33,677评论 0 25
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 34,834评论 1 278
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 50,558评论 3 383
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 47,033评论 2 368

推荐阅读更多精彩内容