Customizing dhcp client hostname in network-manager


I’m using network-manager to connect different wireless and wired networks.

When requesting new ip address through dhcp, system’s hostname value put into the dhcp request as default.

It is possible to customize dhcp hostname value per interface with using hostname option in /etc/network/interfaces file but is there a similar functionality for every configured wireless ssid profile in network-manager? I need to customize dhcp hostname value for configured wireless networks.


Network-Manager has a lot of features. You can customize dhcp client-hostname or any other option for every network profile which is managed by the network-manager (not just wireless ones).

But, there is no GUI for this type of advanced customizations. You have to use network-manager’s cli utility which is named as nmcli.

First of all, list configured profiles in console (just run these commands as normal user, sudo access not needed):

$ nmcli con
NAME                UUID                                  TYPE             DEVICE 
VodafoneNet-9A4BX1  0c56f145-05d0-4b72-946e-c9e4a95cb962  802-11-wireless  --     
miyaki              0bdcc6d1-133d-4fb4-81bd-137ebf6945f3  vpn  --     
TP-LINK_AP_18480    89d6dfff-1cc0-4833-8c8b-a2727be847d6  802-11-wireless  wlan1      
Wired connection 1  8cadcf80-2dd6-4198-a41b-f8e04380f1dc  802-3-ethernet   --   

Now we can get all of the details of a specific profile with nmcli con show command with giving profile name as last argument:

$ nmcli con show TP-LINK_AP_18480                          TP-LINK_AP_18480
connection.uuid:                        89d6dfff-1cc0-4833-8c8b-a2727be847d6
802-11-wireless.ssid:                   TP-LINK_AP_18480
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     imac
^^^^^^^^^^^^^^^^^^^                     ^^^^
DHCP4.OPTION[1]:                        requested_routers = 1
DHCP4.OPTION[2]:                        requested_domain_search = 1
DHCP4.OPTION[3]:                        network_number =

It gives very long output, I just include some parts of it.

You need to change ipv4.dhcp-hostname option which has current value as imac according the above output. To change a variable, nmcli con modify command must be used as below:

$ nmcli con modify TP-LINK_AP_18480 ipv4.dhcp-hostname "my-custom-hostname-01"

After that, network-manager will use your newly configured hostname when connecting to this wireless ssid network.

You should also check nmcli man page for other usages: