diff --git a/nixos/doc/manual/release-notes/rl-1903.xml b/nixos/doc/manual/release-notes/rl-1903.xml
index 49f475913d8..cedd5fc21c6 100644
--- a/nixos/doc/manual/release-notes/rl-1903.xml
+++ b/nixos/doc/manual/release-notes/rl-1903.xml
@@ -111,6 +111,16 @@
without Syncthing resetting the permission on every start.
+
+
+ The ntp module now has sane default restrictions.
+ If you're relying on the previous defaults, which permitted all queries
+ and commands from all firewall-permitted sources, you can set
+ services.ntp.restrictDefault and
+ services.ntp.restrictSource to
+ [].
+
+
Package rabbitmq_server is renamed to
diff --git a/nixos/modules/services/networking/ntpd.nix b/nixos/modules/services/networking/ntpd.nix
index 32174100b0f..588d1c6edb0 100644
--- a/nixos/modules/services/networking/ntpd.nix
+++ b/nixos/modules/services/networking/ntpd.nix
@@ -15,6 +15,10 @@ let
configFile = pkgs.writeText "ntp.conf" ''
driftfile ${stateDir}/ntp.drift
+ restrict default ${toString cfg.restrictDefault}
+ restrict -6 default ${toString cfg.restrictDefault}
+ restrict source ${toString cfg.restrictSource}
+
restrict 127.0.0.1
restrict -6 ::1
@@ -36,11 +40,40 @@ in
enable = mkOption {
default = false;
description = ''
- Whether to synchronise your machine's time using the NTP
- protocol.
+ Whether to synchronise your machine's time using ntpd, as a peer in
+ the NTP network.
+
+
+ Disables systemd.timesyncd if enabled.
'';
};
+ restrictDefault = mkOption {
+ type = types.listOf types.str;
+ description = ''
+ The restriction flags to be set by default.
+
+
+ The default flags prevent external hosts from using ntpd as a DDoS
+ reflector, setting system time, and querying OS/ntpd version. As
+ recommended in section 6.5.1.1.3, answer "No" of
+ http://support.ntp.org/bin/view/Support/AccessRestrictions
+ '';
+ default = [ "limited" "kod" "nomodify" "notrap" "noquery" "nopeer" ];
+ };
+
+ restrictSource = mkOption {
+ type = types.listOf types.str;
+ description = ''
+ The restriction flags to be set on source.
+
+
+ The default flags allow peers to be added by ntpd from configured
+ pool(s), but not by other means.
+ '';
+ default = [ "limited" "kod" "nomodify" "notrap" "noquery" ];
+ };
+
servers = mkOption {
default = config.networking.timeServers;
description = ''
@@ -51,6 +84,7 @@ in
extraFlags = mkOption {
type = types.listOf types.str;
description = "Extra flags passed to the ntpd command.";
+ example = literalExample ''[ "--interface=eth0" ]'';
default = [];
};