Bug 378259 - [RFE] NetworkManager does not send new hostname to DHCP server
Summary: [RFE] NetworkManager does not send new hostname to DHCP server
Status: REPORTED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_networkmanagement (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Jan Grulich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-30 02:50 UTC by DHCP Easyness
Modified: 2024-12-23 18:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
KDE nm-editor dialog IPv4 tab screenshot (18.34 KB, image/png)
2017-03-30 02:50 UTC, DHCP Easyness
Details

Note You need to log in before you can comment on or make changes to this bug.
Description DHCP Easyness 2017-03-30 02:50:08 UTC
Created attachment 104806 [details]
KDE nm-editor dialog IPv4 tab screenshot

Trying to send a different (or blank) hostname to the DHCP request on a wireless interface (wlp3s0). NetworkManager (and the KDE nm-editor) doesn't seem to allow this or make this happen, no matter what I tried.

Using vanilla Kubuntu 16.10 Live CD (with security updates current) IPv4 only.  I have observed this issue for a long time on previous versions, though. Hostname is the default: kubuntu

1. Tried to enter in DHCP Client ID hostname (asdfl87Gad) in nm-editor (see attached screenshot).  This added
 dhcp-client-id=asdfl87Gad
to the [ipv4] section of /etc/NetworkManager/system-connections/Guest and added
 send dhcp-client-identifier "asdfl87Gad"; # added by NetworkManager
to the end of /var/lib/NetworkManager/dhclient-wlp3s0.conf but there still was a line
 send host-name "kubuntu"; # added by NetworkManager
in that file, and
 tcpdump -nvvi wlp3s0 port 68
showed
 Hostname Option 12, length 7: "kubuntu"
was still being sent "on the wire"(less)

2. Looked at man NetworkManager (not so useful) and (more useful)
 man nm-settings
and found dhcp-hostname (string) and dhcp-send-hostname (boolean, default TRUE) in the Table 13. ipv4 setting section. Added
 dhcp-hostname=asdfl87Gad
 dhcp-send-hostname=true
to the [ipv4] section of /etc/NetworkManager/system-connections/Guest but tcpdump still showed
 Hostname Option 12, length 7: "kubuntu"
and the end of /var/lib/NetworkManager/dhclient-wlp3s0.conf had
 send dhcp-client-identifier "asdfl87Gad"; # added by NetworkManager
 send host-name "kubuntu"; # added by NetworkManager

3. On a whim, in /etc/NetworkManager/system-connections/Guest I changed
 dhcp-send-hostname=false
and modified /etc/dhcp/dhclient.conf
 #send host-name = gethostname();
 supersede host-name "asdfl87Gad";
 send host-name "asdfl87Gad";
 request subnet-mask, broadcast-address, time-offset, routers,
 #       domain-name, domain-name-servers, domain-search, host-name,
         domain-name, domain-name-servers, domain-search,
 #       dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
and restarted NetworkManager
 service NetworkManager restart
which removed from the end of /var/lib/NetworkManager/dhclient-wlp3s0.conf 
 send host-name "kubuntu"; # added by NetworkManager
and tcpdump -nvvi wlp3s0 port 68 finally showed
 Hostname Option 12, length 10: "asdfl87Gad"

So, while I was able to accomplish this, I had to edit a lot of text files, and I'm not sure exactly what made it work.

Relevant excerpts from my files follow:

/etc/dhcp/dhclient.conf

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send host-name = gethostname();
supersede host-name "asdfl87Gad";
send host-name  "asdfl87Gad";
request subnet-mask, broadcast-address, time-offset, routers,
#	domain-name, domain-name-servers, domain-search, host-name,
	domain-name, domain-name-servers, domain-search,
#	dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
... (SNIP) ...

/etc/NetworkManager/system-connections/Guest

[connection]
id=Guest
uuid=[__MASKED__]
type=wifi
autoconnect=false
permissions=user:kubuntu:;
secondaries=

[wifi]
mac-address-blacklist=
mac-address-randomization=0
mode=infrastructure
seen-bssids=
ssid=Guest

[ipv4]
dhcp-client-id=asdfl87Gad
dhcp-hostname=asdfl87Gad
dhcp-send-hostname=false
dns-search=
ignore-auto-dns=true
may-fail=false
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=link-local


/var/lib/NetworkManager/dhclient-wlp3s0.conf

# Created by NetworkManager
# Merged from /etc/dhcp/dhclient.conf

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#	man page for more information about the syntax of this file
#	and a more comprehensive list of the parameters understood by
#	dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#	not leave anything out (like the domain name, for example), then
#	few changes must be made to this file, if any.
#
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send host-name = gethostname();
supersede host-name "asdfl87Gad";
send host-name  "asdfl87Gad";
request subnet-mask, broadcast-address, time-offset, routers,
#	domain-name, domain-name-servers, domain-search, host-name,
domain-name, domain-name-servers, domain-search,
#	dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
... (SNIP) ...
send dhcp-client-identifier "asdfl87Gad"; # added by NetworkManager

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option ms-classless-static-routes code 249 = array of unsigned integer 8;
option wpad code 252 = string;

also request rfc3442-classless-static-routes;
also request ms-classless-static-routes;
also request static-routes;
also request wpad;
also request ntp-servers;
Comment 1 Jan Grulich 2017-03-30 08:03:15 UTC
It appears that dhcp-client-identifier is something else and that we miss option to set dhcp-hostname and dhcp-send-hostname. I checked  both nm-connection-editor and gnome-control-center and none of them allows to set this as well. Maybe this is something not used that often on desktop / by regular users and supporting this would just bloat our UI with unnecessary stuff used by only a minority of people. We can check this further if there is hight demend for this, but right now I would suggest using nmcli or other tool to set this.
Comment 2 V. Ram 2019-01-20 01:27:49 UTC
@Jan Grulich

One way this could be canonically addressed is if there were a global way to control or halt dhcp hostnames going out in the dhcp requests by NetworkManager.  Unfortunately, as per this NM bug: https://bugzilla.gnome.org/show_bug.cgi?id=768076 , this does not look like it will be fixed any time soon.

For that reason, it is very hard for anyone using plasma-nm to actually stop NM from leaking the hostname.  

Agree with you that most NM GUI frontends do not help expose/control these settings, but doing so is essential to privacy and it seems surprising this has been unresolved for so long.  It is possible to hand-edit the network entries, but it's also trivial for plasma-nm to overwrite these handcrafted settings.

Since KDE is aiming toward privacy, e.g., https://phabricator.kde.org/T7050 , and since plasma-nm is the primary means by which any KDE user will be dealing with the whole non-trivial NetworkManager + dhclient + systemd stack, plasma-nm has the chance to take the lead here and put control back in the hands of users without forcing them to deal with nmcli.

This could (and ideally would) be done via user-visible/adjustable global options, to include things like MAC address spoofing, and dhcp-send-hostname, which would then be incorporated into per-connection settings.  That way, any new connection at a coffee shop, hotel, etc., would prevent unique info leakage via dhcp.  Even if this is not feasible, at least making such options visible at the per-connection level would help.

Please do not consider this "[bloating the] UI with unnecessary stuff used by only a minority of people" - it is really the only way to be true to a privacy-centric approach.