{"id":268,"date":"2021-02-12T23:28:52","date_gmt":"2021-02-12T15:28:52","guid":{"rendered":"https:\/\/blog.swineson.me\/en\/?p=268"},"modified":"2021-02-12T23:29:50","modified_gmt":"2021-02-12T15:29:50","slug":"dhcp-server-on-juniper-srx","status":"publish","type":"post","link":"https:\/\/blog.swineson.me\/en\/dhcp-server-on-juniper-srx\/","title":{"rendered":"DHCP Server on Juniper SRX"},"content":{"rendered":"<p>This article provides everything you need to setup a local DHCP server on a SRX security device.<\/p>\n<p><!--more--><\/p>\n<h1>JDHCPD vs DHCPD<\/h1>\n<p>JDHCPD provides more functionalities than DHCPD, so it is recommended to use JDHCPD on new setups. (<a href=\"https:\/\/www.juniper.net\/documentation\/en_US\/junos\/topics\/topic-map\/dhcp-local-server-extended-for-routing-devices.html#id-extended-dhcp-local-server-overview\" target=\"_blank\" rel=\"noopener\">Feature comparison<\/a>)<\/p>\n<h1>DHCP and uRPF<\/h1>\n<p>If you have uRPF and DHCP setup on the same interface, by default all DHCP traffic will be dropped. To make DHCP work, you need to set up an exemption:<\/p>\n<pre class=\"lang:default decode:true\">set firewall filter rpf-exception term dhcp from protocol udp\r\nset firewall filter rpf-exception term dhcp from port dhcp\r\nset firewall filter rpf-exception term dhcp then count dhcp\r\nset firewall filter rpf-exception term dhcp then accept\r\n\r\nset interfaces &lt;interface-name&gt; family inet rpf-check fail-filter rpf-exception<\/pre>\n<h1>Using the (New) JDHCPD<\/h1>\n<p>This is the recommended method. (<a href=\"https:\/\/www.juniper.net\/documentation\/en_US\/junos\/topics\/topic-map\/dhcp-local-server-extended-for-routing-devices.html\" target=\"_blank\" rel=\"noopener\">Official documentation<\/a>)<\/p>\n<h2>In the Default Routing Instance<\/h2>\n<p>Note: this is what I use in my production environment. You might need to adjust some lines to match your needs. Also I have multiple groups and IP ranges, that&#8217;s why I used a config group so that I can apply the same config to all the IP ranges.<\/p>\n<pre class=\"lang:default decode:true\">set system services dhcp-local-server group default-group interface &lt;interface-name&gt; [upto &lt;interface-name&gt;] [exclude]\r\nset system services dhcp-local-server pool-match-order ip-address-first\r\nset system services dhcp-local-server pool-match-order option-82\r\nset system services dhcp-local-server route-suppression access-internal\r\nset system services dhcp-local-server requested-ip-interface-match\r\n\r\nset groups DHCP_SERVER_DEFAULTS access address-assignment pool &lt;*&gt; family inet dhcp-attributes maximum-lease-time 600\r\nset groups DHCP_SERVER_DEFAULTS access address-assignment pool &lt;*&gt; family inet dhcp-attributes domain-name corp.contoso.com\r\nset groups DHCP_SERVER_DEFAULTS access address-assignment pool &lt;*&gt; family inet dhcp-attributes name-server 8.8.8.8\r\nset groups DHCP_SERVER_DEFAULTS access address-assignment pool &lt;*&gt; family inet dhcp-attributes name-server 8.8.4.4\r\n\r\nset access address-assignment pool LAN family inet apply-groups DHCP_SERVER_DEFAULTS\r\nset access address-assignment pool LAN family inet network 192.168.1.0\/24\r\nset access address-assignment pool LAN family inet range 0 low 192.168.1.100\r\nset access address-assignment pool LAN family inet range 0 high 192.168.1.200\r\nset access address-assignment pool LAN family inet dhcp-attributes router 192.168.1.1<\/pre>\n<h2>In a Non-default Routing Instance or Logical System<\/h2>\n<p>Just config everything in the corresponding RI or LS.<\/p>\n<pre class=\"lang:default decode:true\">set routing-instances VR1 system services dhcp-local-server group default-group interface &lt;interface-name&gt; [upto &lt;interface-name&gt;] [exclude]\r\nset routing-instances VR1 system services dhcp-local-server pool-match-order ip-address-first\r\nset routing-instances VR1 system services dhcp-local-server pool-match-order option-82\r\nset routing-instances VR1 system services dhcp-local-server route-suppression access-internal\r\nset routing-instances VR1 system services dhcp-local-server requested-ip-interface-match\r\n\r\nset groups DHCP_SERVER_DEFAULTS routing-instances &lt;*&gt; access address-assignment pool &lt;*&gt; family inet dhcp-attributes maximum-lease-time 600\r\nset groups DHCP_SERVER_DEFAULTS routing-instances &lt;*&gt; access address-assignment pool &lt;*&gt; family inet dhcp-attributes domain-name corp.contoso.com\r\nset groups DHCP_SERVER_DEFAULTS routing-instances &lt;*&gt; access address-assignment pool &lt;*&gt; family inet dhcp-attributes name-server 8.8.8.8\r\nset groups DHCP_SERVER_DEFAULTS routing-instances &lt;*&gt; access address-assignment pool &lt;*&gt; family inet dhcp-attributes name-server 8.8.4.4\r\n\r\nset routing-instances VR1 access address-assignment pool LAN family inet apply-groups DHCP_SERVER_DEFAULTS\r\nset routing-instances VR1 access address-assignment pool LAN family inet network 192.168.1.0\/24\r\nset routing-instances VR1 access address-assignment pool LAN family inet range 0 low 192.168.1.100\r\nset routing-instances VR1 access address-assignment pool LAN family inet range 0 high 192.168.1.200\r\nset routing-instances VR1 access address-assignment pool LAN family inet dhcp-attributes router 192.168.1.1<\/pre>\n<h2>Debugging<\/h2>\n<pre class=\"lang:default decode:true\">show dhcp server binding [routing-instance &lt;instance-name&gt;]<\/pre>\n<p>To trace:<\/p>\n<pre class=\"lang:default decode:true\">set system processes dhcp-service traceoptions level all\r\nset system processes dhcp-service traceoptions flag all\r\n<\/pre>\n<p>The default log file name is <span class=\"lang:default highlight:0 decode:true crayon-inline \">jdhcpd<\/span> .<\/p>\n<h1>Using the (legacy) DHCPD<\/h1>\n<pre class=\"lang:default decode:true \">set system services dhcp pool 192.168.1.0\/24 address-range low 192.168.1.100\r\nset system services dhcp pool 192.168.1.0\/24 address-range high 192.168.1.200\r\nset system services dhcp pool 192.168.1.0\/24 router 192.168.1.1\r\nset system services dhcp pool 192.168.1.0\/24 name-server 8.8.8.8\r\nset system services dhcp pool 192.168.1.0\/24 name-server 8.8.4.4\r\nset system services dhcp pool 192.168.1.0\/24 domain-name corp.contoso.com\r\nset system services dhcp pool 192.168.1.0\/24 default-lease-time 3600\r\nset system services dhcp pool 192.168.1.0\/24 maximum-lease-time 3600\r\n<\/pre>\n<h2>Debugging<\/h2>\n<pre class=\"lang:default decode:true\">show system services dhcp pool\r\nshow system services dhcp binding [&lt;ip-address&gt;] [detail]\r\nshow system services dhcp conflict<\/pre>\n<p>To trace:<\/p>\n<pre class=\"lang:default decode:true\">set system services dhcp traceoptions flag all<\/pre>\n<p>The default log file name is <span class=\"lang:default highlight:0 decode:true crayon-inline \">dhcpd<\/span> .<\/p>\n<h1>References<\/h1>\n<ul>\n<li><a href=\"https:\/\/sites.google.com\/site\/networkingwheels\/unicast-reverse-path-forwarding-urpf-with-juniper-devices\" target=\"_blank\" rel=\"noopener\">Unicast Reverse Path Forwarding (URPF) with Juniper Devices<\/a><\/li>\n<\/ul>\n<div class=\"ms-editor-squiggler\" style=\"color: initial; font: initial; font-feature-settings: initial; font-kerning: initial; font-optical-sizing: initial; font-variation-settings: initial; text-orientation: initial; text-rendering: initial; -webkit-font-smoothing: initial; -webkit-locale: initial; -webkit-text-orientation: initial; -webkit-writing-mode: initial; writing-mode: initial; zoom: initial; place-content: initial; place-items: initial; place-self: initial; alignment-baseline: initial; animation: initial; appearance: initial; aspect-ratio: initial; backdrop-filter: initial; backface-visibility: initial; background: initial; background-blend-mode: initial; baseline-shift: initial; block-size: initial; border-block: initial; border: initial; border-radius: initial; border-collapse: initial; border-inline: initial; inset: initial; box-shadow: initial; box-sizing: initial; break-after: initial; break-before: initial; break-inside: initial; buffered-rendering: initial; caption-side: initial; caret-color: initial; clear: initial; clip: initial; clip-path: initial; clip-rule: initial; color-interpolation: initial; color-interpolation-filters: initial; color-rendering: initial; color-scheme: initial; columns: initial; column-fill: initial; gap: initial; column-rule: initial; column-span: initial; contain: initial; contain-intrinsic-size: initial; content: initial; content-visibility: initial; counter-increment: initial; counter-reset: initial; counter-set: initial; cursor: initial; cx: initial; cy: initial; d: initial; display: block; dominant-baseline: initial; empty-cells: initial; fill: initial; fill-opacity: initial; fill-rule: initial; filter: initial; flex: initial; flex-flow: initial; float: initial; flood-color: initial; flood-opacity: initial; grid: initial; grid-area: initial; height: 0px; hyphens: initial; image-orientation: initial; image-rendering: initial; inline-size: initial; inset-block: initial; inset-inline: initial; isolation: initial; letter-spacing: initial; lighting-color: initial; line-break: initial; list-style: initial; margin-block: initial; margin: initial; margin-inline: initial; marker: initial; mask: initial; mask-type: initial; max-block-size: initial; max-height: initial; max-inline-size: initial; max-width: initial; min-block-size: initial; min-height: initial; min-inline-size: initial; min-width: initial; mix-blend-mode: initial; object-fit: initial; object-position: initial; offset: initial; opacity: initial; order: initial; origin-trial-test-property: initial; orphans: initial; outline: initial; outline-offset: initial; overflow-anchor: initial; overflow-wrap: initial; overflow: initial; overscroll-behavior-block: initial; overscroll-behavior-inline: initial; overscroll-behavior: initial; padding-block: initial; padding: initial; padding-inline: initial; page: initial; page-orientation: initial; paint-order: initial; perspective: initial; perspective-origin: initial; pointer-events: initial; position: initial; quotes: initial; r: initial; resize: initial; ruby-position: initial; rx: initial; ry: initial; scroll-behavior: initial; scroll-margin-block: initial; scroll-margin: initial; scroll-margin-inline: initial; scroll-padding-block: initial; scroll-padding: initial; scroll-padding-inline: initial; scroll-snap-align: initial; scroll-snap-stop: initial; scroll-snap-type: initial; shape-image-threshold: initial; shape-margin: initial; shape-outside: initial; shape-rendering: initial; size: initial; speak: initial; stop-color: initial; stop-opacity: initial; stroke: initial; stroke-dasharray: initial; stroke-dashoffset: initial; stroke-linecap: initial; stroke-linejoin: initial; stroke-miterlimit: initial; stroke-opacity: initial; stroke-width: initial; tab-size: initial; table-layout: initial; text-align: initial; text-align-last: initial; text-anchor: initial; text-combine-upright: initial; text-decoration: initial; text-decoration-skip-ink: initial; text-indent: initial; text-overflow: initial; text-shadow: initial; text-size-adjust: initial; text-transform: initial; text-underline-offset: initial; text-underline-position: initial; touch-action: initial; transform: initial; transform-box: initial; transform-origin: initial; transform-style: initial; transition: initial; user-select: initial; vector-effect: initial; vertical-align: initial; visibility: initial; -webkit-app-region: initial; border-spacing: initial; -webkit-border-image: initial; -webkit-box-align: initial; -webkit-box-decoration-break: initial; -webkit-box-direction: initial; -webkit-box-flex: initial; -webkit-box-ordinal-group: initial; -webkit-box-orient: initial; -webkit-box-pack: initial; -webkit-box-reflect: initial; -webkit-highlight: initial; -webkit-hyphenate-character: initial; -webkit-line-break: initial; -webkit-line-clamp: initial; -webkit-mask-box-image: initial; -webkit-mask: initial; -webkit-mask-composite: initial; -webkit-perspective-origin-x: initial; -webkit-perspective-origin-y: initial; -webkit-print-color-adjust: initial; -webkit-rtl-ordering: initial; -webkit-ruby-position: initial; -webkit-tap-highlight-color: initial; -webkit-text-combine: initial; -webkit-text-decorations-in-effect: initial; -webkit-text-emphasis: initial; -webkit-text-emphasis-position: initial; -webkit-text-fill-color: initial; -webkit-text-security: initial; -webkit-text-stroke: initial; -webkit-transform-origin-x: initial; -webkit-transform-origin-y: initial; -webkit-transform-origin-z: initial; -webkit-user-drag: initial; -webkit-user-modify: initial; white-space: initial; widows: initial; width: initial; will-change: initial; word-break: initial; word-spacing: initial; x: initial; y: initial; z-index: initial;\"><\/div>\n<div class=\"ms-editor-squiggler\" style=\"color: initial; font: initial; font-feature-settings: initial; font-kerning: initial; font-optical-sizing: initial; font-variation-settings: initial; text-orientation: initial; text-rendering: initial; -webkit-font-smoothing: initial; -webkit-locale: initial; -webkit-text-orientation: initial; -webkit-writing-mode: initial; writing-mode: initial; zoom: initial; place-content: initial; place-items: initial; place-self: initial; alignment-baseline: initial; animation: initial; appearance: initial; aspect-ratio: initial; backdrop-filter: initial; backface-visibility: initial; background: initial; background-blend-mode: initial; baseline-shift: initial; block-size: initial; border-block: initial; border: initial; border-radius: initial; border-collapse: initial; border-inline: initial; inset: initial; box-shadow: initial; box-sizing: initial; break-after: initial; break-before: initial; break-inside: initial; buffered-rendering: initial; caption-side: initial; caret-color: initial; clear: initial; clip: initial; clip-path: initial; clip-rule: initial; color-interpolation: initial; color-interpolation-filters: initial; color-rendering: initial; color-scheme: initial; columns: initial; column-fill: initial; gap: initial; column-rule: initial; column-span: initial; contain: initial; contain-intrinsic-size: initial; content: initial; content-visibility: initial; counter-increment: initial; counter-reset: initial; counter-set: initial; cursor: initial; cx: initial; cy: initial; d: initial; display: block; dominant-baseline: initial; empty-cells: initial; fill: initial; fill-opacity: initial; fill-rule: initial; filter: initial; flex: initial; flex-flow: initial; float: initial; flood-color: initial; flood-opacity: initial; grid: initial; grid-area: initial; height: 0px; hyphens: initial; image-orientation: initial; image-rendering: initial; inline-size: initial; inset-block: initial; inset-inline: initial; isolation: initial; letter-spacing: initial; lighting-color: initial; line-break: initial; list-style: initial; margin-block: initial; margin: initial; margin-inline: initial; marker: initial; mask: initial; mask-type: initial; max-block-size: initial; max-height: initial; max-inline-size: initial; max-width: initial; min-block-size: initial; min-height: initial; min-inline-size: initial; min-width: initial; mix-blend-mode: initial; object-fit: initial; object-position: initial; offset: initial; opacity: initial; order: initial; origin-trial-test-property: initial; orphans: initial; outline: initial; outline-offset: initial; overflow-anchor: initial; overflow-wrap: initial; overflow: initial; overscroll-behavior-block: initial; overscroll-behavior-inline: initial; overscroll-behavior: initial; padding-block: initial; padding: initial; padding-inline: initial; page: initial; page-orientation: initial; paint-order: initial; perspective: initial; perspective-origin: initial; pointer-events: initial; position: initial; quotes: initial; r: initial; resize: initial; ruby-position: initial; rx: initial; ry: initial; scroll-behavior: initial; scroll-margin-block: initial; scroll-margin: initial; scroll-margin-inline: initial; scroll-padding-block: initial; scroll-padding: initial; scroll-padding-inline: initial; scroll-snap-align: initial; scroll-snap-stop: initial; scroll-snap-type: initial; shape-image-threshold: initial; shape-margin: initial; shape-outside: initial; shape-rendering: initial; size: initial; speak: initial; stop-color: initial; stop-opacity: initial; stroke: initial; stroke-dasharray: initial; stroke-dashoffset: initial; stroke-linecap: initial; stroke-linejoin: initial; stroke-miterlimit: initial; stroke-opacity: initial; stroke-width: initial; tab-size: initial; table-layout: initial; text-align: initial; text-align-last: initial; text-anchor: initial; text-combine-upright: initial; text-decoration: initial; text-decoration-skip-ink: initial; text-indent: initial; text-overflow: initial; text-shadow: initial; text-size-adjust: initial; text-transform: initial; text-underline-offset: initial; text-underline-position: initial; touch-action: initial; transform: initial; transform-box: initial; transform-origin: initial; transform-style: initial; transition: initial; user-select: initial; vector-effect: initial; vertical-align: initial; visibility: initial; -webkit-app-region: initial; border-spacing: initial; -webkit-border-image: initial; -webkit-box-align: initial; -webkit-box-decoration-break: initial; -webkit-box-direction: initial; -webkit-box-flex: initial; -webkit-box-ordinal-group: initial; -webkit-box-orient: initial; -webkit-box-pack: initial; -webkit-box-reflect: initial; -webkit-highlight: initial; -webkit-hyphenate-character: initial; -webkit-line-break: initial; -webkit-line-clamp: initial; -webkit-mask-box-image: initial; -webkit-mask: initial; -webkit-mask-composite: initial; -webkit-perspective-origin-x: initial; -webkit-perspective-origin-y: initial; -webkit-print-color-adjust: initial; -webkit-rtl-ordering: initial; -webkit-ruby-position: initial; -webkit-tap-highlight-color: initial; -webkit-text-combine: initial; -webkit-text-decorations-in-effect: initial; -webkit-text-emphasis: initial; -webkit-text-emphasis-position: initial; -webkit-text-fill-color: initial; -webkit-text-security: initial; -webkit-text-stroke: initial; -webkit-transform-origin-x: initial; -webkit-transform-origin-y: initial; -webkit-transform-origin-z: initial; -webkit-user-drag: initial; -webkit-user-modify: initial; white-space: initial; widows: initial; width: initial; will-change: initial; word-break: initial; word-spacing: initial; x: initial; y: initial; z-index: initial;\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article provides everything you need to setup a local DHCP server on a SRX security device.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","hentry","category-junos-os"],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/posts\/268"}],"collection":[{"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":2,"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/posts\/268\/revisions"}],"predecessor-version":[{"id":270,"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/posts\/268\/revisions\/270"}],"wp:attachment":[{"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/media?parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/categories?post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.swineson.me\/en\/wp-json\/wp\/v2\/tags?post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}