Juniper Zero Touch Configuration (ZTP) Part 3 - DHCP Server Setup

Posted September 20, 2017 by Matthew McGeehan

DHCP is a crucial part of the zero touch provisioning process. The DHCP server will need to be configured to send out specific options. These options will be used to instruct the switch on which image to install and what config file to apply.

Depending on the DHCP server that is setup there are a couple of different things that can be done. Options can be setup on a global level for all members in the DHCP scope or per reservation based on the switches mac address. For my test, I setup on installed DHCP on a Linux box running CentOS7. DHCP scopes are configured under /etc/dhcp/dhcpd.conf. An example file can be found in /usr/share/doc/dhcp-your-version/dhcpd.conf.example.

DHCP install steps:

  1. Run the following command to install the DHCP server.
    • sudo yum install dhcp
  2. Configure /etc/dhcp/dhcpd.conf
  3. Set Nginx to start on system boot
    • sudo systemctl enable dhcpd
  4. Start the Nginx service
    • sudo systemctl start nginx
  5. Any changes made to dhcpd.conf will require a restart of the service.

Example dhcp.conf:

Below is an example file that can be used to test a ZTP setup.

            # For this example I had an interface on the Linux server in the range
            subnet netmask {
                    option routers;
                    option subnet-mask;
                    default-lease-time 3600;
                    max-lease-time 7200;

            option space zerop;
            option zerop-file-server code 150 = { ip-address };

            option zerop.config-file-name code 1 = text;
            option zerop.transfer-mode code 3 = text;
            option zerop-encapsulation code 43 = encapsulate zerop;
            option zerop.config-file-name "leaf.config";

             ## Location of HTTP server.  In this example it's the DHCP server but it could be a separate system.
            option zerop-file-server; 
            ## How files should be transferred. This is set to TFTP by default.
            option zerop.transfer-mode "http";

            group {
                    host SPINE { 
                    ## You can specify the MAC address of the switch to give it a specific configuration.
                    hardware ethernet 33:33:33:33:33:33;
                    ## IP address assigned to the switch
                    ## This option will be used to specify the config file location 
                    option zerop.config-file-name "spine.config";
  1. In the example above, DHCP will hand out IP addresses from the IP range.
    • subnet netmask
  2. Configuration and image files for ZTP will be transferred using HTTP.
    • option zerop.transfer-mode "http
  3. The file server's IP address is
    • option ztp-file-server;
  4. Lastly, a reservation is specified for mac address 33:33:33:33:33:33 This device will be directed to install the config file SPINE.conf.

That's it for a basic deployment of ZTP. At this point you should be able to unbox an EX or QFX switch and pull down a configuration file. Stay tuned for the next update to see how to take it up a notch. In my next post, I will go over how to automate the config file and DHCP reservation process using Python and Jinja2.