From c232d4b587b2b9521c549c06ba93fdb45630106a Mon Sep 17 00:00:00 2001 From: 0x4A6F <0x4A6F@users.noreply.github.com> Date: Wed, 30 Sep 2020 21:21:23 +0000 Subject: [PATCH] nixos: Conform with RFC 1123 in networking.hostName Conform to RFC 1123 [0], specifically to "2.1 Host Names and Numbers", which allow starting host name with alphanumerical instead of alphabetical characters. RFC 1123 updates RFC 952 [1], which is referenced in "man 5 hosts". [0]: https://tools.ietf.org/html/rfc1123 [1]: https://tools.ietf.org/html/rfc952 --- nixos/doc/manual/release-notes/rl-2009.xml | 4 ++-- nixos/modules/tasks/network-interfaces.nix | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2009.xml b/nixos/doc/manual/release-notes/rl-2009.xml index ff5b50132ee..4122a1fb8e5 100644 --- a/nixos/doc/manual/release-notes/rl-2009.xml +++ b/nixos/doc/manual/release-notes/rl-2009.xml @@ -594,8 +594,8 @@ systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ]; The hostname (networking.hostName) must now be a valid - DNS label (see RFC 1035) and as such must not contain the domain part. - This means that the hostname must start with a letter, end with a letter + DNS label (see RFC 1035, RFC 1123) and as such must not contain the domain part. + This means that the hostname must start with a letter or digit, end with a letter or digit, and have as interior characters only letters, digits, and hyphen. The maximum length is 63 characters. Additionally it is recommended to only use lower-case characters. diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 9ff2326db1f..b956f49c036 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -381,13 +381,14 @@ in # syntax). Note: We also allow underscores for compatibility/legacy # reasons (as undocumented feature): type = types.strMatching - "^$|^[[:alpha:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$"; + "^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$"; description = '' The name of the machine. Leave it empty if you want to obtain it from a DHCP server (if using DHCP). The hostname must be a valid DNS label (see - RFC 1035 section 2.3.1: "Preferred name syntax") and as such must not - contain the domain part. This means that the hostname must start with a - letter, end with a letter or digit, and have as interior characters only + RFC 1035 section 2.3.1: "Preferred name syntax", RFC 1123 section 2.1: + "Host Names and Numbers") and as such must not contain the domain part. + This means that the hostname must start with a letter or digit, + end with a letter or digit, and have as interior characters only letters, digits, and hyphen. The maximum length is 63 characters. Additionally it is recommended to only use lower-case characters. '';