# Setting time from router



## balanga (Oct 14, 2017)

How do I set the time on my RPi2 from my router?


----------



## aragats (Oct 14, 2017)

What's wrong with setting time with ntpd(8)?


----------



## ralphbsz (Oct 14, 2017)

In some older versions, NTP was unwilling to make a big change in the time.  In those old days, I used to run "rdate" to a known good time server right after boot to get an initial setting.  Today, you can do that when starting ntpd, by using the -g option (perhaps in combination with -q if you want to run just once, not keep it running as a daemon).


----------



## Phishfry (Oct 14, 2017)

`ntpdate pool.ntp.org`


----------



## ShelLuser (Oct 14, 2017)

But to answer: same way as you'd set the time from any other NTP server, see the responses above. You could substitute pool.ntp.org for your routers IP address in the example from Phishfry .

Of course, this is also assuming that your router actually provides NTP functionality.


----------



## balanga (Oct 14, 2017)

I want to do this on booting.... Not sure what to put in /etc/rc.conf...


----------



## Phishfry (Oct 14, 2017)

Looks like `ntpdate` is depreciated anyway:
https://www.freebsd.org/cgi/man.cgi?query=ntpdate&sektion=8

https://www.freebsd.org/doc/handbook/network-ntp.html

So my new oneshot is:
`ntpd -gq pool.ntp.org`

For persistence:
/etc/rc.conf gets this with /etc/ntp.conf holding settings:
ntpd_enable="YES"


----------



## Phishfry (Oct 14, 2017)

I noticed that /etc/ntp.conf already includes a pool with this line:

```
pool 0.freebsd.pool.ntp.org iburst
```
So the option flags are all that is needed for a oneshot.
`ntpd -gq`


----------



## Phishfry (Oct 14, 2017)

balanga said:


> How do I set the time on my RPi2 from my router?


This is pretty broad "my router"

Assuming you are using pfSense (since I have helped you over there) And you are running an ntp server on pfSense.
You would need to comment-out pool and add your pfSense address for the ntp server.


----------

