diff --git a/package/gluon-wan-dnsmasq/Makefile b/package/gluon-wan-dnsmasq/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..14b9efa65e063bf5d89dc37ec23530c5efd199ae
--- /dev/null
+++ b/package/gluon-wan-dnsmasq/Makefile
@@ -0,0 +1,35 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-wan-dnsmasq
+PKG_VERSION:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gluon-wan-dnsmasq
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=Support for a secondary DNS server using the WAN interface
+  DEPENDS:=+gluon-core +dnsmasq
+endef
+
+define Package/gluon-wan-dnsmasq/description
+	Gluon community wifi mesh firmware framework: Support for a secondary DNS server using the WAN interface
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-wan-dnsmasq/install
+	$(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,gluon-wan-dnsmasq))
diff --git a/package/gluon-wan-dnsmasq/files/etc/hotplug.d/iface/50-gluon-wan-dnsmasq b/package/gluon-wan-dnsmasq/files/etc/hotplug.d/iface/50-gluon-wan-dnsmasq
new file mode 100644
index 0000000000000000000000000000000000000000..d559e9b13274dd709ae364d5ed8f463f6a91d90f
--- /dev/null
+++ b/package/gluon-wan-dnsmasq/files/etc/hotplug.d/iface/50-gluon-wan-dnsmasq
@@ -0,0 +1,3 @@
+if [ "$INTERFACE" = 'wan' -o "$INTERFACE" = 'wan6' ]; then
+   /lib/gluon/wan-dnsmasq/update.lua
+fi
diff --git a/package/gluon-wan-dnsmasq/files/etc/init.d/gluon-wan-dnsmasq b/package/gluon-wan-dnsmasq/files/etc/init.d/gluon-wan-dnsmasq
new file mode 100755
index 0000000000000000000000000000000000000000..790c686351e23ead4b55794483867263a4063555
--- /dev/null
+++ b/package/gluon-wan-dnsmasq/files/etc/init.d/gluon-wan-dnsmasq
@@ -0,0 +1,26 @@
+#!/bin/sh /etc/rc.common
+
+START=60
+
+SERVICE_NAME=gluon-wan-dnsmasq
+SERVICE_USE_PID=1
+SERVICE_PID_FILE=/var/run/gluon-wan-dnsmasq.pid
+
+
+PORT=54
+PACKET_MARK=1
+
+RESOLV_CONF_DIR=/var/gluon/wan-dnsmasq
+RESOLV_CONF=$RESOLV_CONF_DIR/resolv.conf
+
+
+start() {
+	mkdir -p $RESOLV_CONF_DIR
+	touch $RESOLV_CONF
+
+	service_start /usr/sbin/dnsmasq -x $SERVICE_PID_FILE -u root -i lo -p $PORT --packet-mark=$PACKET_MARK -h -r $RESOLV_CONF
+}
+
+stop() {
+	service_stop /usr/sbin/dnsmasq
+}
diff --git a/package/gluon-wan-dnsmasq/files/lib/gluon/wan-dnsmasq/update.lua b/package/gluon-wan-dnsmasq/files/lib/gluon/wan-dnsmasq/update.lua
new file mode 100755
index 0000000000000000000000000000000000000000..cf65e8d6c7d873992944b8dcd96705d8cccf8f55
--- /dev/null
+++ b/package/gluon-wan-dnsmasq/files/lib/gluon/wan-dnsmasq/update.lua
@@ -0,0 +1,25 @@
+#!/usr/bin/lua
+
+local RESOLV_CONF_DIR = '/var/gluon/wan-dnsmasq'
+local RESOLV_CONF = RESOLV_CONF_DIR .. '/resolv.conf'
+
+
+local ubus = require('ubus').connect()
+local fs = require 'nixio.fs'
+
+
+local function write_servers(f, iface)
+  local servers = ubus:call('network.interface.' .. iface, 'status', {}).inactive['dns-server']
+  for _, server in ipairs(servers) do
+    f:write('nameserver ', server, '\n')
+  end
+end
+
+
+fs.mkdirr(RESOLV_CONF_DIR)
+local f = io.open(RESOLV_CONF, 'w+')
+
+pcall(write_servers, f, 'wan6')
+pcall(write_servers, f, 'wan')
+
+f:close()