Bookmark and Share BitCoin Donate: 13t8gAWVpHP2ddxMp88d1NFpZjnFJC6UwK


People connecting to the Internet through a, sometimes transparent, proxy server or behind a firewall, in corporate or education-like environments, often have access to the HTTP and HTTPS protocols only. Since NTP requires access to outgoing and incoming packets from UDP port 123, synchronizing the system time with this protocol is somewhat difficult. If no LAN-accesable NTP server is available, one can synchronize the time using HTTP, and htpdate can handle this job (with an accuracy of +-0.5 seconds).
Code: Install htpdate

emerge -tv htpdate

The following command shows how to query (-q) a random web page in verbose mode (-d) using a proxy address (-P).
Code: Query the server for the current time


To set the system time, simply replace -q option with -s.
Code: Synchronize the system time


That's it. Additionally, instead of using, or, I recommend that you choose web servers that are hosted near you (near in terms of TCP/IP routes, not pseudo-geographical location). For instance, a site might be hosted in a North American datacenter. Your town hall web site may always be a good reference.

You might also want to run htpdate as a daemon. As root, edit /etc/conf.d/htpdate by specifying at least one correct Internet web page, setting up the correct proxy address (if needed) and, eventually, adding additional options (check the man page). Then rc-update add htpdate default and /etc/init.d/htpdate start.