Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

How to have dedicated DHCP options bind to a specific SSID?

xiaodoudou edited this page Sep 15, 2015 · 7 revisions

Identify SSID Interface

As the following configuration is applied to a specific interface, you need to identify which interface / virtual interface your SSID is using, to do so you can use the following command:

nvram show | grep WiFiTest

Which should result something similar to:

wl0.2_ssid=WiFiTest
size: 48528 bytes (17008 left)
wl_ssid=WiFiTest

This example give us wl0.2 as the interface that we need to tweak.

Scripts

DNSMasq Script

Create the following file:

/jffs/scripts/dnsmasq.postconf

Give it the following permission:

chmod +xxx /jffs/scripts/dnsmasq.postconf

Its content should be:

#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
logger "dnsmasq-dhcp: Configure wl0.2 to have special DHCP"
ifconfig wl0.2 172.30.20.2 netmask 255.255.255.0
iptables -D INPUT -i wl0.2 -j ACCEPT
iptables -I INPUT -i wl0.2 -j ACCEPT
ebtables -t broute -D BROUTING -i wl0.2 -p ipv4 -j DROP
ebtables -t broute -I BROUTING -i wl0.2 -p ipv4 -j DROP
pc_append "
log-dhcp
interface=wl0.2
dhcp-option=wl0.2,3,172.30.20.1
dhcp-option=wl0.2,6,8.8.8.8,8.8.4.4
" /tmp/etc/dnsmasq.conf

Feel free to customize the DHCP option and range.

Service-start Script

You need to create this file to ensure the DHCP service is restarted after the WiFi interface have been mounted. Create the following file:

/jffs/scripts/services-start

Give it the following permission:

chmod +xxx /jffs/scripts/services-start

Its content should be:

#!/bin/sh
service restart_dnsmasq

Debug

You can restart the dnsmasq server by doing service:

service restart_dnsmasq

It does avoid to reboot the router.

Also ensure you DHCP configuration have the following configuration:

log-dhcp

This last one produce more advance logs that could help you. Example:

637407747 available DHCP range: 172.30.20.2 -- 172.30.20.254
637407747 vendor class: MSFT 5.0
637407747 client provides name: Eric-PC
637407747 DHCPREQUEST(br0) 172.30.20.231 00:ff:57:99:d8:98 
637407747 tags: lan, br0
637407747 DHCPACK(br0) 172.30.20.231 00:ff:57:99:d8:98 Eric-Sekkei
637407747 requested options: 1:netmask, 15:domain-name, 3:router, 6:dns-server, 
637407747 requested options: 44:netbios-ns, 46:netbios-nodetype, 47:netbios-scope, 
637407747 requested options: 31:router-discovery, 33:static-route, 121:classless-static-route, 
637407747 requested options: 249, 252, 43:vendor-encap
637407747 next server: 172.30.20.1
637407747 sent size:  1 option: 53 message-type  5
637407747 sent size:  4 option: 54 server-identifier  172.30.20.1
637407747 sent size:  4 option: 51 lease-time  1d
637407747 sent size:  4 option: 58 T1  12h
637407747 sent size:  4 option: 59 T2  21h
637407747 sent size:  4 option:  1 netmask  255.255.255.0
637407747 sent size:  4 option: 28 broadcast  172.30.20.255
637407747 sent size: 14 option: 81 FQDN  03:ff:ff:45:72:69:63:2d:53:65:6b:6b:65:69
637407747 sent size:  1 option:252   0a
637407747 sent size:  8 option:  6 dns-server  172.30.20.1, 172.30.20.1
637407747 sent size:  4 option:  3 router  172.30.20.1
Clone this wiki locally