# Setting time in jails



## ghostcorps (Apr 14, 2012)

Hi guys,

 I am running FreeBSD 8.1 with two jails, but for some reason the clocks are out of sync, by a day in one case. While looking at options I found advice that I must use OpenNTPd for jails. 

 I have installed OpenNTPd as follows on all clients:

/etc/rc.conf

```
openntpd_enable="YES"
```

/usr/local/etc/ntpd.conf

```
server  nist1-ny.ustiming.org
```

/etc/ipfw.rules

```
$IPF 40 allow udp from any to any 123 in
```

 I first stopped ntpd but when I start OpenNTPd on either of the jails I get this:

`# /usr/local/etc/rc.d/openntpd start`

```
Starting openntpd.
reset adjtime failed: Operation not permitted
```
nb.  There is no error posted when I start it on the host.

 The status shows normal on all clients:
`# /usr/local/etc/rc.d/openntpd status`

```
openntpd is running as pid xxxxx xxxxx xxxxx.
```

 When I stop it I get this on all the clients:
`# /usr/local/etc/rc.d/openntpd stop`

```
Stopping openntpd.
kill: xxxxx: No such process
kill: xxxxx: No such process
```
nb. These pids are shown in top as ntpd prior to stopping it.

 I get this from ntpdate on all clients:
`# ntpdate -d`

```
13 Apr 19:50:57 ntpdate[90757]: ntpdate 4.2.4p5-a (1)
13 Apr 19:50:57 ntpdate[90757]: no servers can be used, exiting
```
nb. the dates shown are still out of sync.

I have confirmed the port is opened to the host and clients:
`# sockstat -4 -p 123`

```
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
_ntp     ntpd       xxxxx 4  udp4   xxx.xxx.xxx.xx1:17158 64.90.182.55:123
_ntp     ntpd       xxxxx 4  udp4   xxx.xxx.xxx.xx2:54007 64.90.182.55:123
_ntp     ntpd       xxxxx 4  udp4   xxx.xxx.xxx.xx3:10168 64.90.182.55:123
```


This is the only thing new in /var/log/messages:

```
dispatch_imsg in main: pipe closed
```
 It appears in all clients logs.

 Am I missing something? Ideally I want to use the host as a local time server and update the jails directly. but for now I just need them all syncing to the same source.


----------



## SirDice (Apr 14, 2012)

Set the clock correctly on the host. Make sure the timezones are correctly configured in the jails. Jails get their time from the host, you can't set it.


----------



## ghostcorps (Apr 14, 2012)

SirDice said:
			
		

> Set the clock correctly on the host. Make sure the timezones are correctly configured in the jails. Jails get their time from the host, you can't set it.



Well that was a little too easy!

Thank you!

For anyone else this page will help


----------

