OpenWrt Forum Archive

Topic: ntpclient problem with static ip address.

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I've installed 7.07 on a motorola 850g, it's going to be used as an openvpn server.

I used ipkg to install ntpclient.

If I let the box pick up a dhcp address for it's wan interface then ntpclient sets the date properly.

If I assign a static ip address to the wan interface in /etc/config/network, then the date is not set.  Creating an /etc/init.d/ntpclient and using /etc/init.d/ntpclient enable to build links into /etc/rc.d makes things work right.

I'm guessing that using a static ip address doesn't generate the necessary hotplug events to call /etc/hotplug.d/iface/20-ntpclient.  Is using the init.d script the Right Thing To Do?

Thanks,
g.

yeah, I found the same in 7.09. I think the hotplug script is to make the ntpclient to set the date when interface status changes. I also wirte the init.d script as a workaround solution, but i am thinking the crontabs maybe a better way. Here is the init.d/ntpclient script for 7.09

#!/bin/sh /etc/rc.common
#Copyright (C) 2006 OpenWrt.org
START=55

ntpclient_config() {
        local cfg="$1"
        config_get hostname     $cfg hostname
        config_get port         $cfg port
        config_get count        $cfg count

        ps | grep 'bin/[n]tpclient' >&- || {
                route -n 2>&- | grep '^0.0.0.0' >&- && {
                        /usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&-
                }
        }
}

start () {
        config_load ntpclient
        config_foreach ntpclient_config ntpclient
}

stop() {
        route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
}

The discussion might have continued from here.