NTP: Difference between revisions

imported>Tobias.bora
No edit summary
imported>IgorM
m Fixed syntax highlighting errors by using lang=text where it was omitted
Line 25: Line 25:


Most of the time the default NTP servers will be reachable. However, sometimes the NTP servers can be blocked by the firewall (for instance most universities block NTP for security reasons). This will be visible in the <code>systemd-timesyncd.service</code>:
Most of the time the default NTP servers will be reachable. However, sometimes the NTP servers can be blocked by the firewall (for instance most universities block NTP for security reasons). This will be visible in the <code>systemd-timesyncd.service</code>:
<syntaxHighlight>
<syntaxHighlight lang=text>
$ sudo systemctl status systemd-timesyncd.service
$ sudo systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
● systemd-timesyncd.service - Network Time Synchronization
Line 34: Line 34:


You can also test a specific server as follows:
You can also test a specific server as follows:
<syntaxHighlight>
<syntaxHighlight lang=text>
$ nix-shell -p ntp
$ nix-shell -p ntp
$ ntpdate -q 0.nixos.pool.ntp.org
$ ntpdate -q 0.nixos.pool.ntp.org
Line 41: Line 41:


However, a replacement NTP is usually provided in that case via the DHCP protocol. You can see it for instance if you use Network Manager:
However, a replacement NTP is usually provided in that case via the DHCP protocol. You can see it for instance if you use Network Manager:
<syntaxHighlight>
<syntaxHighlight lang=text>
$ nmcli connection show 'name-of-the-current-connection' | grep ntp
$ nmcli connection show 'name-of-the-current-connection' | grep ntp
DHCP4.OPTION[8]:                        ntp_servers = 192.168.x.y
DHCP4.OPTION[8]:                        ntp_servers = 192.168.x.y
Line 51: Line 51:


You might also be able to get the actual hostname of the DHCP (if it exists) using:
You might also be able to get the actual hostname of the DHCP (if it exists) using:
<syntaxHighlight>
<syntaxHighlight lang=text>
$ sudo nmap -sP 192.168.x.y
$ sudo nmap -sP 192.168.x.y
</syntaxHighlight>
</syntaxHighlight>