Skip to content

How to have dedicated DHCP options bind to a specific SSID

이요 edited this page Oct 23, 2023 · 1 revision

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.

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-range=wl0.2,172.30.20.150,172.30.20.200,255.255.255.0,86400s
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.

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

You can restart the dnsmasq server by doing service:

service restart_dnsmasq

It does avoid to reboot the router.

Also ensure your DHCP configuration have the following configuration:

log-dhcp

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

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

Clone this wiki locally