What's new
  • 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!

Problem with wan-start script

bilboSNB

Senior Member
Hello, since upgrading to the latest firmware 374.42 on my n66u my wan start script appears to have stopped working properly. In the log I see that the dnscrypt certificates are not being accepted due to the network time not being updated.

Code:
#!/bin/sh

# Wait up to 15 seconds to make sure /opt partition is mounted
i=0
while [ $i -le 15 ]
do
    if [ -d /opt/tmp ]
    then
        break
    fi
    sleep 1
    i=`expr $i + 1`
done

# Now resolve DNS name for NTP server
rm -f /jffs/configs/hosts.add
ntp_name=$(nvram get ntp_server0)
for ip in $(/opt/sbin/dnscrypt-proxy-hostip $ntp_name)
do
    echo $ip $ntp_name >> /jffs/configs/hosts.add
done

# and restart NTP client to eliminate 4-5 mins delay
killall ntp && sleep 2
service restart_ntpc

Can any one suggest a modification? Running the script again manually seems to work.

Many thanks.
 
Try

Code:
#!/bin/sh

# Wait up to 15 seconds to make sure /opt partition is mounted
i=0
while [ $i -le 15 ]
do
    if [ -d /opt/tmp ]
    then
        break
    fi
    sleep 1
    i=`expr $i + 1`
done

# Now resolve DNS name for NTP server
ntp_name=$(nvram get ntp_server0)
grep "$ntp_name" /jffs/configs/hosts.add > /dev/null 2>&1 || \
for ip in $(/opt/sbin/dnscrypt-proxy-hostip $ntp_name)
do
    echo $ip $ntp_name >>  /jffs/configs/hosts.add
done

# Restart dnsmasq
service restart_dnsmasq && sleep 1

# and restart NTP client to eliminate 4-5 mins delay
killall ntp && sleep 1
service restart_ntpc

The above script works fine for me without including the unbound and ad blocking bits.

Also, ensure the file ownership and permissions of hosts.add are set to admin:root and 777 as well as dnscrypt-proxy-hostip installed via opkg
 
Thanks, your script is working.

It looks very similar to the original script used for opendns crypt which did not used to work for me hence what I was using above till the latest firmware update. ??

Anyways, all good now.
 
Glad you got it working again :)

The main difference is in the method of replacing existing ntp host/s and ip/s with new host/s and ip/s in the hosts.add file vs /etc/hosts (the original method which no longer works) and restarting dnsmasq before the ntp service.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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