GNOME Bugzilla – Bug 778004
domain name does not get set to DHCP parameters
Last modified: 2020-11-12 14:32:39 UTC
I'm running Centos 7.3 (1611 updated) on a small farm of servers. I have an OpenWRT firewall running dnsmasq as the DHCP server. The hosts are configured as: NetworkManager 1.4.0 linux 3.10.0 ISC dhclient 4.2.5 My /etc/sysconfig/network file is effectively empty (except for a comment). My ethernet connection is configured as: connection.id: eno1 connection.uuid: 9a876b0d-cf74-4dc9-8d1f-f67be51dcd00 connection.stable-id: -- connection.interface-name: eno1 connection.type: 802-3-ethernet connection.autoconnect: yes connection.autoconnect-priority: 0 connection.timestamp: 1485899676 connection.read-only: no connection.permissions: connection.zone: -- connection.master: -- connection.slave-type: -- connection.autoconnect-slaves: -1 (default) connection.secondaries: connection.gateway-ping-timeout: 0 connection.metered: unknown connection.lldp: -1 (default) 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 802-3-ethernet.duplex: -- 802-3-ethernet.auto-negotiate: yes 802-3-ethernet.mac-address: -- 802-3-ethernet.cloned-mac-address: -- 802-3-ethernet.generate-mac-address-mask:-- 802-3-ethernet.mac-address-blacklist: 802-3-ethernet.mtu: auto 802-3-ethernet.s390-subchannels: 802-3-ethernet.s390-nettype: -- 802-3-ethernet.s390-options: 802-3-ethernet.wake-on-lan: 1 (default) 802-3-ethernet.wake-on-lan-password: -- ipv4.method: auto ipv4.dns: ipv4.dns-search: ipv4.dns-options: (default) ipv4.dns-priority: 0 ipv4.addresses: ipv4.gateway: -- ipv4.routes: ipv4.route-metric: -1 ipv4.ignore-auto-routes: no ipv4.ignore-auto-dns: no ipv4.dhcp-client-id: -- ipv4.dhcp-timeout: 0 ipv4.dhcp-send-hostname: yes ipv4.dhcp-hostname: -- ipv4.dhcp-fqdn: -- ipv4.never-default: no ipv4.may-fail: yes ipv4.dad-timeout: -1 (default) ipv6.method: auto ipv6.dns: ipv6.dns-search: ipv6.dns-options: (default) ipv6.dns-priority: 0 ipv6.addresses: ipv6.gateway: -- ipv6.routes: ipv6.route-metric: -1 ipv6.ignore-auto-routes: no ipv6.ignore-auto-dns: no ipv6.never-default: no ipv6.may-fail: yes ipv6.ip6-privacy: -1 (unknown) ipv6.addr-gen-mode: stable-privacy ipv6.dhcp-send-hostname: yes ipv6.dhcp-hostname: -- ipv6.token: -- GENERAL.NAME: eno1 GENERAL.UUID: 9a876b0d-cf74-4dc9-8d1f-f67be51dcd00 GENERAL.DEVICES: eno1 GENERAL.STATE: activated GENERAL.DEFAULT: yes GENERAL.DEFAULT6: no GENERAL.VPN: no GENERAL.ZONE: -- GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/9 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/2 GENERAL.SPEC-OBJECT: / GENERAL.MASTER-PATH: -- IP4.ADDRESS[1]: 192.168.1.53/24 IP4.GATEWAY: 192.168.1.252 IP4.DNS[1]: 192.168.1.252 IP4.DOMAIN[1]: redfish-solutions.com DHCP4.OPTION[1]: requested_classless_static_routes = 1 DHCP4.OPTION[2]: requested_rfc3442_classless_static_routes = 1 DHCP4.OPTION[3]: subnet_mask = 255.255.255.0 DHCP4.OPTION[4]: requested_subnet_mask = 1 DHCP4.OPTION[5]: domain_name_servers = 192.168.1.252 DHCP4.OPTION[6]: ip_address = 192.168.1.53 DHCP4.OPTION[7]: requested_static_routes = 1 DHCP4.OPTION[8]: dhcp_server_identifier = 192.168.1.252 DHCP4.OPTION[9]: requested_nis_servers = 1 DHCP4.OPTION[10]: requested_time_offset = 1 DHCP4.OPTION[11]: broadcast_address = 192.168.1.255 DHCP4.OPTION[12]: requested_interface_mtu = 1 DHCP4.OPTION[13]: dhcp_rebinding_time = 35290 DHCP4.OPTION[14]: requested_domain_name_servers = 1 DHCP4.OPTION[15]: dhcp_message_type = 5 DHCP4.OPTION[16]: requested_broadcast_address = 1 DHCP4.OPTION[17]: routers = 192.168.1.252 DHCP4.OPTION[18]: dhcp_renewal_time = 19090 DHCP4.OPTION[19]: requested_domain_name = 1 DHCP4.OPTION[20]: domain_name = redfish-solutions.com DHCP4.OPTION[21]: requested_routers = 1 DHCP4.OPTION[22]: expiry = 1485942238 DHCP4.OPTION[23]: host_name = kvm1 DHCP4.OPTION[24]: requested_wpad = 1 DHCP4.OPTION[25]: requested_nis_domain = 1 DHCP4.OPTION[26]: requested_ms_classless_static_routes = 1 DHCP4.OPTION[27]: network_number = 192.168.1.0 DHCP4.OPTION[28]: requested_domain_search = 1 DHCP4.OPTION[29]: next_server = 192.168.1.252 DHCP4.OPTION[30]: requested_ntp_servers = 1 DHCP4.OPTION[31]: ntp_servers = 192.168.1.40 DHCP4.OPTION[32]: dhcp_lease_time = 43200 DHCP4.OPTION[33]: requested_host_name = 1 IP6.ADDRESS[1]: fe80::7a51:4743:f861:a93f/64 IP6.GATEWAY: my current lease file looks like: ... lease { interface "eno1"; fixed-address 192.168.1.53; option subnet-mask 255.255.255.0; option routers 192.168.1.252; option dhcp-lease-time 43200; option dhcp-message-type 5; option domain-name-servers 192.168.1.252; option dhcp-server-identifier 192.168.1.252; option dhcp-renewal-time 19090; option ntp-servers 192.168.1.40; option broadcast-address 192.168.1.255; option dhcp-rebinding-time 35290; option host-name "kvm1"; option domain-name "redfish-solutions.com"; renew 3 2017/02/01 02:46:17; rebind 3 2017/02/01 07:32:08; expire 3 2017/02/01 09:43:58; } hostnamectl tells me: Static hostname: localhost.localdomain Transient hostname: kvm1 Icon name: computer-server Chassis: server Machine ID: d4033d25d4854fcd9268f676a73fd109 Boot ID: d2c9c81e089649d1ab0203e3e5463146 Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-514.6.1.el7.x86_64 Architecture: x86-64 I get "kvm1" from "hostname" and "kvm1.redfish-solutions.com" from "hostname -f". And I get "" from "domainname". Why am I not getting "kvm1.redfish-solutions.com" from "hostname", which is what I get if I turn off NetworkManager.service and enable the dumb init.d scripts called "network.service" instead? The lack of a domain name means that postfix is convinced my domain is ".localdomain" and I have to manually set it otherwise. I tried hacking my /etc/dhcp/dhclient.conf file to have: also require fqdn.fqdn; but this made no difference. The only place that the domain name seems to turn up is in /etc/resolv.conf as the "search" parameter (but curiously not as the "domain" parameter). Please add a knob to force the machine's hostname to be set to the FQDN by NetworkManager when using DHCP.
Regarding the /etc/resolv.conf discrepancy of "search" via "domain", the DHCP option 119 is pretty clearly what was intended to populate the "search" parameter(s), per RFC-3397 Section 2, and DHCP option 15 per RFC-2132 is intended for the "domain".
Per the IRC discussion, there are two separate issues with domain/search: 1) resolv.conf - this only affects things that call gethostbyname(3) and use the glibc resolver to look up a name. We stopped NM setting 'domain' between 0.9.8 and 0.9.10 for some reason (see https://bugzilla.gnome.org/show_bug.cgi?id=729137) so if the server doesn't send any searches, then it appears that NM won't set either domain or search in resolv.conf. Not sure if that's a problem. 2) system hostname - Philip's problem is that he is expecting the system hostname to be set to the DHCP hostname combined with the DHCP domain name, and NM basically discards the domain part. NM only cares about the DHCP hostname if there isn't already a persistent hostname. So perhaps if there is no persistent hostname, NM could combine the DHCP hostname and domain (if both are valid *and* if the hostname is not an FQDN already) and use that as the transient system hostname. Not sure if that'll break any existing configurations that use DHCP-provided hostnames that aren't FQDNs though.
Created attachment 345478 [details] Validated via /etc/dhcp/dhclient.d/hostname.sh script
Created attachment 345485 [details] Corrected version of /etc/dhcp/dhclient.d/hostname.sh
bugzilla.gnome.org is being shut down in favor of a GitLab instance. We are closing all old bug reports and feature requests in GNOME Bugzilla which have not seen updates for a long time. If you still use NetworkManager and if you still see this bug / want this feature in a recent and supported version of NetworkManager, then please feel free to report it at https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/ Thank you for creating this report and we are sorry it could not be implemented (workforce and time is unfortunately limited).