# Wireless interface prevents ntp-client from starting at boot

## 96140

Okay. I just successfully switched from a wired internet connection to a wireless, WPA-PSK setup. Everything works great, except . . .

Now, ntpdate doesn't run at startup. Yes, I have net.ath0 (my wireless interface) now added to the default runlevel. I deleted and then re-added ntp-client to default, thinking that this would make it start up after the network interface was activated, but I'm having no luck so far.

Now, once my system is booted and I've logged in, I can manually run "ntpdate -b -u pool.ntp.org" with no problems. My clock is always offset by 14 seconds, but it still re-syncs itself correctly. The problem is, it doesn't do this on boot.

net.ath0 is a symlink to net.lo. Now, net.lo was originally just set to runlevel <boot>, but I also had to add it to <default> as well, so that ath0 would work correctly. Here's my current rc status:

```
net.lo | boot default

net.ath0 |      default

ntp-client |      default
```

Also, I do have dhcpcd_ath0="-N" set in /etc/conf.d/net, just so that any ntp configs aren't overwritten. But, what gives? Is ntp-client still trying to use the old net.eth0 (wired) interface? Or do I need to somehow adjust the execution order of my init scripts once the computer enters the default runlevel? Or what?

----------

## 96140

I removed net.lo from runlevel <default>, and net.ath0 still comes up correctly at startup, so that's a relief.  :Smile:  I guess having net.lo in a runlevel besides <boot> doesn't really affect anything. I thought it might, since net.ath0 is just a symlink to it.

However, ntp-client still can't contact a server, probably because it is being brought up before the net interface is initialized. Anyone have any ideas? Is there something I can put in local.start, or specify a startup order somewhere, or do I need to come up with some sort of pre-up/post-up script?

----------

## PaulBredbury

See the new sections "Service Dependency" and "Clock Accuracy at Reboot" at the wiki entry.

----------

## 96140

 *PaulBredbury wrote:*   

> See the new sections "Service Dependency" and "Clock Accuracy at Reboot" at the wiki entry.

 

Thanks. I've edited /etc/init.d/ntp-client. We'll see how it works at the next reboot.

----------

## 96140

 *nightmorph wrote:*   

>  *PaulBredbury wrote:*   See the new sections "Service Dependency" and "Clock Accuracy at Reboot" at the wiki entry. 
> 
> Thanks. I've edited /etc/init.d/ntp-client. We'll see how it works at the next reboot.

 

Nope. Didn't work. ntp-client still can't connect at startup.

----------

## TheRAt

Are there any error messages in the logs?

Could you post the ntp-client config file?

----------

## PaulBredbury

Increase the sleep delay in postup(), as explained in the wiki article.

----------

## 96140

 *TheRAt wrote:*   

> Are there any error messages in the logs?
> 
> Could you post the ntp-client config file?

 

Nope. The only messages I see on boot are as follows:

```
Error: temporary failure in name resolution

ntpdate [pid#]: can't find host pool.ntp.org

ntpdate [pid#]: no servers can be used, exiting.

* Failed to set clock
```

My conf.d/ntp-client is as follows:

```
NTPCLIENT_CMD="ntpdate"

NTPCLIENT_OPTS=" -b -u pool.ntp.org"

NTPCLIENT_TIMEOUT=30
```

The thing is, once I'm booted up into Gnome (or the console), manually setting the date with "ntpdate -b -u pool.ntp.org" works perfectly. I'll try increasing the delay, though, in hopes that it works.

----------

## TheRAt

Can you start ntp-client successfully after you have booted up?

```
/etc/init.d/ntp-client stop

/etc/init.d/ntp-client start
```

----------

## 96140

 *TheRAt wrote:*   

> Can you start ntp-client successfully after you have booted up?
> 
> ```
> /etc/init.d/ntp-client stop
> 
> ...

 

Yes. No errors there. And ntpdate runs fine on its own, with or without ntp-client running.

However, on boot, despite increasing the "wait" period to 15 seconds in the postup() function of /etc/conf.d/net, it's like that file isn't even checked. There certainly was no 15-second period, just the usual 3-4 seconds of attempting to connect to the ntp server, followed by the failure message. Previously, when I was using a wired connection, it took the same 3 seconds to connect to the ntp servers. So the time hasn't changed at all. I wish I knew why the wait time is being ignored. Here is the postup() function I use:

```
# To fully bring up ath0 before allowing ntp-client to run at startup

postup() {

        # Wait for connection to be ready to communicate

        sleep 15

        return 0

}
```

However, this appears after a predown() function . . . do I just need to switch the order of the functions? Will try that and reboot. However, I can't tell exactly when ath0 is brought up, as it's managed by hotplug. Or coldplug. Or something. Either way, my new wireless interface doesn't have the same boot up script as the old wired one did. There are none of the familiar "bringing up net.xxx0; mounting network filesystems" messages etc. Now, if I manually run /etc/init.d/ath0 restart, then I see those status messages. But they don't show up during boot.

----------

## PaulBredbury

 *nightmorph wrote:*   

> However, on boot, despite increasing the "wait" period to 15 seconds in the postup() function of /etc/conf.d/net, it's like that file isn't even checked.

 

Don't you mean "net.ath0"?  What line did you put in /etc/init.d/ntp-client? Have you run:

```
rc-update add net.ath0 default
```

Also, take a look at /etc/conf.d/rc - you probably want:

```
RC_NET_STRICT_CHECKING="yes"
```

----------

## 96140

Rebooting after switching the order of the functions didn't work. Still no 15 second delay.

 *PaulBredbury wrote:*   

> Don't you mean "net.ath0"?

 

No, /etc/conf.d/net is global for all net interfaces.

 *Quote:*   

> What line did you put in /etc/init.d/ntp-client?

 

The line in /etc/init.d/ntp-client is:

```
depend() {

        before cron portmap

        need net

        after net.ath0

        use dns logger

}
```

The only thing I added to this section was "after net.ath0".

 *Quote:*   

> Have you run:
> 
> ```
> rc-update add net.ath0 default
> ```
> ...

 

See my first post in this thread. Yes, I have. It's added to the default runlevel; that's why I have a working internet connection.

 *Quote:*   

> Also, take a look at /etc/conf.d/rc - you probably want:
> 
> ```
> RC_NET_STRICT_CHECKING="yes"
> ```
> ...

 

Will try this and reboot. After reading the comments for this option, it finally makes some sense; I guess this might be useful in my situation.

EDIT:Nope, rebooting after changing strict net checking to "yes" didn't work.

----------

## PaulBredbury

 *nightmorph wrote:*   

> No, /etc/conf.d/net is global for all net interfaces.

 

The postup() should be in /etc/init.d/net.ath0. Only ath0 needs a pause after it, and the pause is specifically for ath0.

----------

## 96140

 *PaulBredbury wrote:*   

>  *nightmorph wrote:*   No, /etc/conf.d/net is global for all net interfaces. 
> 
> The postup() should be in /etc/init.d/net.ath0. Only ath0 needs a pause after it, and the pause is specifically for ath0.

 

Well, I edited the file as specified. However, as I stated earlier, net.ath0 is symlinked to net.lo, so editing "init.d/net.ath0" is really editing net.lo. So I think that the sleep function will be used twice now, once when net.lo is brought up on boot, and the second when ath0 is activated. Would it work if I just removed net.atho and copied net.lo to net.ath0, then added in the sleep function? Or do net interfaces besides lo need to be symlinks back to lo? I just noticed that with this baselayout, net.eth0 is no longer its own script, but is also symlinked to net.lo.  :Exclamation: 

Also, do I still need to keep RC_STRICT_NET_CHECKING="yes" in /etc/conf.d/rc?

----------

## PaulBredbury

I'm not sure what the deal is with having symlinks - I think these init scripts have gotten too complex for their own good  :Confused:   My /etc/init.d/net.ath0 is something like:

```
#!/sbin/runscript

# Copyright 1999-2004 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.lo,v 1.10 2004/04/21 17:09:18 vapier Exp $

depend() {

        need net

}

start() {

        ebegin "Bringing ${IFACE} up"

        /sbin/modprobe ath_hal

        /sbin/modprobe ath_pci

        /sbin/modprobe wlan_wep

        /sbin/ifconfig ath0 192.168.1.8 up

        /sbin/iwconfig ath0 mode master

        /sbin/iwconfig ath0 essid 1264

        /sbin/iwconfig ath0 key open 32419283479182742389457129

        /sbin/iwconfig ath0 channel 9

        # mode 3 is 11g - speed will be 3mb/s instead of 1mb/s.

        /sbin/iwpriv ath0 mode 3

        eend 0

}

stop() {

        ebegin "Bringing ${IFACE} down"

        /sbin/ifconfig ${IFACE} down

        /sbin/modprobe -r ath_pci

        /sbin/modprobe -r ath_hal

        /sbin/modprobe -r wlan_wep

        eend 0

}
```

Which makes it pretty easy to put a "sleep 5" in the line before "eend 0"  :Wink: 

----------

## 96140

Hmm, but mine does not--and cannot--look anything like that. I use wpa_supplicant exclusively; iwconfig is no good for me. Interesting, though.

Also, rebooting with the proper entry for the function in /etc/init.d/net.ath0 (net.lo) doesn't work, either. Any time delay I put in is still ignored.

----------

## PaulBredbury

You could put the sleep command at the start of the start() function in /etc/init.d/ntp-client. It would be, strictly-speaking, an inappropriate place, but it would solve the problem  :Smile: 

----------

## 96140

In fact, this worked. I have "sleep 4" in the beginning ntp-client start() function. It does, of course, automatically add still more time to my boot process, but at least it works now. I'm still on the lookout for the "real" fix to the problem; perhaps it will be in the next stable baselayout update.

----------

## aries

Hello nightmorph,

Is your problem with ntp-client already solved with a new baselayout?

Or are you still using the "sleep 4" solution?

It looks like I'm having the same problem with ntp wich only want to start on my wired and not on my wireless.

----------

## 96140

It's intermittent, actually. Most of the time, especially with the last two stable versions of baselayout I've used, I haven't needed the sleep function. Recently, I've had issues with ntpdate not being able to reach the servers after I've associated with my AP and received an IP address. However, networking works fine. I suspect in those cases that I just had a high signal:noise ratio or something, which meant it took too long for things to finalize before ntpdate kicked in. Darned thick apartment walls. Unlike later versions, baselayout 1.11.14-r2 works extremely well with my (older) version of madwifi-driver, and association time is very quick, certainly quicker than it used to be. Even so, sometimes it just doesn't connect when it needs to.

----------

