[WORKAROUND] Mounting USB before starting dnsmasq, SmartDNS?

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
Particle Man
DD-WRT Novice


Joined: 07 Jun 2021
Posts: 15

PostPosted: Mon Jun 14, 2021 18:55    Post subject: [WORKAROUND] Mounting USB before starting dnsmasq, SmartDNS? Reply with quote
Router: ASUS RT-AC1900P / RT-AC68P
dnsmasq (with addn-hosts), SmartDNS (DoT); USB (ext2) mounted on /jffs

Services > USB:
Automatic Drive Mount: Enable
Mount this Partition to /jffs: populated with the UUID

When smartdns.conf and addn-hosts were on the internal flash, dnsmasq and SmartDNS automatically started at bootup without issue.

But due to JFFS2 issues (mainly "Error garbage collecting note at ...!" since "compression type 0x06 not available" didn't matter?), I migrated /jffs to a USB flash drive.

But with /jffs on USB, dnsmasq is started before the USB is mounted, so I have to manually start it via CLI, which is not sustainable.

syslog:
Quote:
daemon.err dnsmasq[1372]: failed to load names from /jffs/dnsmasq/hosts.txt: No such file or directory
...
kern.info kernel: hub 2-0:1.0: USB hub found
kern.info kernel: hub 2-0:1.0: 2 ports detected
kern.info kernel: usb 1-2: new high-speed USB device number 2 using ehci-pci
kern.info kernel: xhci_hcd 0000:00:0c.0: xHCI Host Controller
kern.info kernel: xhci_hcd 0000:00:0c.0: new USB bus registered, assigned bus number 3
kern.info kernel: xhci_hcd 0000:00:0c.0: hcc params 0x02501164 hci version 0x100 quirks 0x00000010
kern.info kernel: hub 3-0:1.0: USB hub found
kern.err kernel: hub 3-0:1.0: config failed, hub doesn't have any ports! (err -19)
kern.info kernel: xhci_hcd 0000:00:0c.0: xHCI Host Controller
kern.info kernel: xhci_hcd 0000:00:0c.0: new USB bus registered, assigned bus number 4
kern.info kernel: usb usb4: We don't know the algorithms for LPM for this host, disabling LPM.
kern.info kernel: hub 4-0:1.0: USB hub found
kern.info kernel: hub 4-0:1.0: 1 port detected
kern.notice kernel: SCSI subsystem initialized
kern.info kernel: usb-storage 1-2:1.0: USB Mass Storage device detected
kern.info kernel: usb-storage 1-2:1.0: Quirks match for vid 4146 pid ba01: 80
kern.info kernel: scsi host0: usb-storage 1-2:1.0
kern.info kernel: usbcore: registered new interface driver usb-storage
...
kern.info kernel: sda: sda1
kern.notice kernel: sd 0:0:0:0: [sda] Attached SCSI removable disk
user.info : cron : daemon successfully stopped
kern.warn kernel: EXT4-fs (sda1): Ignoring removed nobh option


Did not work:
Services > USB > Run-on-mount Script Name: /jffs/etc/dnsmasq/restart_dns.sh
Code:
stopservice dnsmasq; startservice dnsmasq; smartdns -c /jffs/etc/smartdns.conf


Can USB be mounted before dnsmasq is started?
If not, how might I work around this issue, such as automating start/restart of dnsmasq after the USB is mounted?


Last edited by Particle Man on Wed Jun 16, 2021 18:36; edited 2 times in total
Sponsor
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1405

PostPosted: Mon Jun 14, 2021 22:37    Post subject: Reply with quote
There is a scripting area in Administration->Commands

then save startup. I think that is what you want... but I do not know your full setup.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Tue Jun 15, 2021 15:48    Post subject: Reply with quote
good base of how to smartdns here
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=323896&postdays=0&postorder=asc&start=30

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Tue Jun 15, 2021 17:49    Post subject: Reply with quote
Perhaps the title of this thread should be, "How to restart dnsmasq, SmartDNS after USB drive successfully mounted?"... since that would likely be more logical considering the delay for the USB drive to mount.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
itwontbewe
DD-WRT User


Joined: 29 Sep 2020
Posts: 259
Location: United States

PostPosted: Tue Jun 15, 2021 20:37    Post subject: Reply with quote
maybe try?
Administration/Command
Paste
Code:
sleep 3
stopservice smartdns
startservice smartdns

Click Save Startup button

it works for me when using unbound with a usb

* try the stop and start in cli first
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Wed Jun 16, 2021 5:28    Post subject: Reply with quote
may be add this command to start up script

is-mounted.sh /jffs

this command will call USB stuff when USB is ready and already available...

and than

sleep 3
stopservice dnsmasq
startservice dnsmasq
smartdns -c /jffs/etc/smartdns.conf

make sure you have those too...

IMPORTANT!
SmartDNS needs to be turned off in the GUI - SmartDNS Resolver - Disable

Dnsmasq settings

Validate DNS Replies (DNSSEC) Disable - (Always turn off when you turn on SmartDNS.

Additional Dnsmasq Options
cache-size=0
server=127.0.0.1#6053

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Particle Man
DD-WRT Novice


Joined: 07 Jun 2021
Posts: 15

PostPosted: Wed Jun 16, 2021 18:30    Post subject: Reply with quote
Thanks for the suggestions. To be clear, the issue was not with making dnsmasq or SmartDNS work. The issue is/was these services starting before the USB is (automatically) mounted.

This workaround does the trick:
Code:
[sleep 3 or is-mounted.sh]
stopservice dnsmasq
startservice dnsmasq
smartdns -c /jffs/etc/smartdns.conf


But, curiously, adding sleep before a restart script (the one-liner in the OP to start/stop/reload) did not work, although it works in the CLI.

While "How to restart dnsmasq, SmartDNS after USB mounts?" addresses this workaround, it does not address the issue.

And I'm unaware of any ramifications of (unintuitively) disabling SmartDNS in the UI (while instead starting it in a script), as it has been working whether disabled or enabled in the UI.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum