info_i_25x25.png See important information about Ubiquiti Devices and KRACK Vulnerability in this article. We will update this document as more information becomes available.

EdgeRouter - Define custom DHCP options

Overview


Readers will learn how to configure the DHCP server to transmit custom options to clients.

Note: This configuration presumes that the DHCP subnet is already configured as described in EdgeMAX - Configure static IP addresses

Steps for DHCP server


To configure a DHCP server, four settings are required:

  • name
  • subnet
  • option number
  • option string

Here is an example of how to set add option 242 to an existing dhcp configuration:

set service dhcp-server global-parameters 'option option-242 code 242 = string;'
set service dhcp-server shared-network-name LABNET subnet 100.0.0.0/24 subnet-parameters 'option option-242 "L2Q=1,L2QVLAN=118";'

 

This shows the DHCP server configuration:

dhcp-server {
global-parameters "option option-242 code 242 = string;" shared-network-name LABNET { subnet 100.0.0.0/24 { default-router 100.0.0.1 dns-server 100.0.0.1 start 100.0.0.10 { stop 100.0.0.100 }
subnet-parameters "option option-242 "L2Q=1,L2QVLAN=123";" } } }

 

Notes


In the example above the custom option string requires quotes to be injected directly into the dhcpd.conf. As literal quotes are not allowed in the cli command we replace our quotes with the special entity format for a quote " this will be translated back to a literal quote when building the dhcpd.conf

The above example helps configure some types of SIP phones to join a specific VLAN after booting.

Warning


The above settings will inject strings directly into the dhcpd.conf with no validation. The result may prevent the daemon from starting properly and may not report any errors when committed. Check the system log after applying these settings to confirm the daemon started properly.