Conditional DHCP

I can confirm that the conditional DHCP works as explained (no surprise really). Just in case it is useful, here's roughly what I did...
This is done on the main DHCP box, and the secondary one has dhcp disabled

#clear current settings
uci del dhcp.lan.dhcp_option
#set default route(3)/DNS(6) for the main LAN dhcp
uci add_list dhcp.lan.dhcp_option='6,8.8.8.8,1.1.1.1,8.8.4.4,1.0.0.1'
uci add_list dhcp.lan.dhcp_option='3,192.168.1.1'
#remove old settings
uci del dhcp.gw1
uci del dhcp.gw2
#create a new tag-set for the 2nd gateway
uci set dhcp.gw2=tag
#clear it to start
uci del dhcp.gw2.dhcp_option
#add the "extended" settings
uci add_list dhcp.gw2.dhcp_option='6,8.8.8.8,144.217.75.55,1.1.1.1,109.236.87.2,8.8.4.4,1.0.0.1'
uci add_list dhcp.gw2.dhcp_option='3,192.168.1.2'
#
#Now set up a machine as default
uci set dhcp.pc1='host'
uci set dhcp.pc1.mac='XX:XX:XX:XX:XX:XX'
uci set dhcp.pc1.name='pc1'
uci set dhcp.pc1.dns='1'
uci set dhcp.pc1.ip='192.168.1.100'
#and then one on the alternative
uci set dhcp.pc2='host'
uci set dhcp.pc2.mac='XX:XX:XX:XX:XX:XX'
uci set dhcp.pc2.name='pc2'
uci set dhcp.pc2.dns='1'
uci set dhcp.pc2.ip='192.168.1.200'
#this one gets the additional "tag"
uci set dhcp.pc2.tag='gw2'

Minor notes/observations...

  • if you use xxx-yyy as a station name, you get errors via UCI. xxx_yyy is fine though.
  • I used copy/paste from example page and it added in tabs instead of spaces, which cause the UCI commands to fail, so make sure you replace tabs with spaces.

Thanks to vgaetera and trendy for the help

2 Likes