OpenWRT/Kamikazi - How to configure dhcp default route/gateway and dns server

Just a quick note in case there is anyone else out there struggling to setup openwrt's Kamikazi dnsmasq server to hand out a default gateway and dns server other than the default. In the old days it was easy enough to just edit the dnsmasq.conf file but with Kamikazi you will want to edit the /etc/config/dhcp file to change default options.

OpenWRT Setting PXE/tftp/next server dhcp option 

Since the dhcp config file just takes standard, well almost, dnsmasq parameters it is not that bad when configuring parameters that don't have multiple entries that are distinguished only by their arguments. (It seems in some places the options have been slightly changed with dashes being turned to underscores for the /etc/config/dhcp configuration file etc.) For example, to setup the tftp/pxe boot server for your dhcp server the following entry under the "config dnsmasq" section does the trick 

option dhcp_boot 'pxelinux.0,mark-desktop,192.168.1.107'

OpenWRT setting the dhcp subnets DNS servers and default route/gateway 

 To set the default route and dns server for a particular subnet that your openwrt router is dishing out ip addresses for, you will need to edit the "config dhcp <zone>" section of the /etc/config/dhcp file. Usually, for your default lan, this is "config dhcp lan". This is where the tricky part,at least for me, comes in. The documentation says to use the standard dnsmasq "dhcp_option" parameter, followed by the arguments that one would use, as per usual, in a dnsmasq config. I assumed that I would need to enter a line per option. eg

config dhcp lan
  .....
 option dhcp_option "6,192.168.1.2" #dns server
 option dhcp_option "3,192.168.1.2" #default route

But this results in only one of the options being handed out to dhcp clients. In fact the clients will receive some other value for the config that was not set. This value is the default value that openwrt uses if none is specified. No error messages are raised. This is a bit annoying as things appear to work, until you check the /etc/resolv.conf or routing table on the client. To get both the gateway and dns server set you need to use the following syntax.

config dhcp lan
  ..... 
  list option dhcp_option "6,192.168.1.2" #dns server
  list option dhcp_option "3,192.168.1.2" #default route

 The "list" part is the important bit!