What's new

Script to allow selective connection on reboot

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

sbsmbm

Occasional Visitor
Hello there!
I have on average 12 connected devices to my rt-Ac68u running merlin's 384.15 - which requires reboot at-least once a week (also trying to figure out why, details in my other post).

What i'd like to know & get help on is a script that can run on reboot and only allow 2 devices to connect immediately (i've assigned ip to my laptop and phone) and the rest can connect say 10mins after thereby allowing the router to settle down after the reboot.

Thanks in advance
 
What i'd like to know & get help on is a script that can run on reboot and only allow 2 devices to connect immediately (i've assigned ip to my laptop and phone) and the rest can connect say 10mins after thereby allowing the router to settle down after the reboot.
For a small number of identified devices - you have approx. 10? (plus the laptop and phone that will be exempt), you could define their MACs to ensure that they do not get DHCP assignment:

/jffs/configs/dnsmasq.conf.add
Code:
dhcp-host=ba:ad:ba:ad:ba:d1,ignore
dhcp-host=ba:ad:ba:ad:ba:d2,ignore

etc.
and to disable the DHCP ignore directives when appropriate

/jffs/scripts/dnsmasq.postconf
Code:
#!/bin/sh

UPSECS="$(grep -o '^[0-9]\+' /proc/uptime)"      # or parse the output of 'uptime'
UPMINS=$((UPSECS / 60))

[ $UPMINS -gt 10 ] && sed  's/^dhcp-host.*ignore/#&/' /etc/dnsmasq.conf
So now if you create a cron job to execute 10 minutes after the BOOT

/jffs/scripts/init-start

Code:
#!/bin/sh

HH=${TIME:0:2};MM=${TIME:3:2}
cru a DHCPWait "$MM $HH * * *" /jffs/scripts/AllowDHCP.sh
/jffs/scripts/AllowDHCP.sh
Code:
#!/bin/sh

service restart_dnsmasq
cru d DHCPWait
it might be a crude solution?
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top