1

How can I change the name of my PC that the router sees when I'm connected (in attached devices)? (Without changing username)

Edit (clarification): Currently, when I connect my laptop wirelessly to a router, it's possible to see my computer's name (an thus my own name, since it's <myname>-XPS-13-9343) via the attached devices screen in the router configuration panel. I want to change the way that my computer is seen to the outside world (for shake of privacy).

Kobi T
  • 1,979
  • 4
  • 22
  • 26
  • What would you like it to be? What does it show currently? What is the hostname of your computer configured to be now (run hostname to see)? – dobey Apr 22 '16 at 14:46
  • 1
    It's currently <myname>-XPS-13-9343. I dont want it to include my name. – Kobi T Apr 22 '16 at 14:48
  • 1
    Why the negative rank? – Kobi T Apr 22 '16 at 18:16
  • Please update your question with all the info asked for. It's not possible to tell whether this question is even on topic from the current amount of info in it. It seems like you are asking how to configure your router, rather than Ubuntu. – dobey Apr 22 '16 at 21:04

2 Answers2

1

Ubuntu 22. To change only the computer name visible by a WiFi router, and not the entire host name of a computer, the DHCP client host name has to be changed in the NetworkManager.

Steps:

  1. Set a host name to be used for new connections: create a new NM config file called e.g. /etc/NetworkManager/conf.d/custom-host-name.conf:

    [connection]
    ipv4.dhcp-hostname=<NEW_HOST_NAME>
    ipv6.dhcp-hostname=<NEW_HOST_NAME>
    

    Note: underscores in host_name are not allowed - NM will ignore such names

  2. Set the same host name for existing connections. (Without this step, existing NetworkManager connections, like WiFi access points you've connected to before, will keep using the real host name):

    List existing connections:

    nmcli con
    

    Set the host name for connections of interest:

    nmcli con mod <CONNECTION_NAME> ipv4.dhcp-hostname <NEW_HOST_NAME>
    nmcli con mod <CONNECTION_NAME> ipv6.dhcp-hostname <NEW_HOST_NAME>
    
  3. Restart the NetworkManager for the changes to take effect:

    sudo systemctl restart NetworkManager.service
    

Notes:

  1. Instead of changing the DHCP client host name, it's possible to disable it. Then a WiFi router would say that the host name is unknown. To do this, follow the same steps, but change these settings instead of *.dhcp-hostname:
    • ipv4.dhcp-send-hostname=false
    • ipv6.dhcp-send-hostname=false
  2. To check which host name is sent to the network by DHCP, one can use tcpdump. Run the command, then connect to a WiFi network - DHCP packets will be dumped:
    sudo tcpdump -n -tttt -vvv -i <NETWORK_INTERFACE_NAME> port 67
    
  • explaining names makes them sit better in the mind, to me. Less magic, more memorable. So: nmcli = Network Manager Command Line Interface; parameter "con" is short for "connections", "mod" for "modify". systemctl for SYSTEM ConTroL. (sudo = do as SU, and SU = superuser/root/all-powerful-being within the context of a linux system), – foo Aug 17 '25 at 08:26
1

Your pc name is saved in /etc/hostname & /etc/hosts files.
On a Terminal, type sudo gedit /etc/hostname command and change the pc name.
Also, change the hostname in sudo gedit /etc/hosts "first line is 127.0.0.1 localhost , second line is 127.0.0.1 "YOUR PC NAME".
Then type this command sudo service hostname restart to restart the service. your PC name is changed.

Jos
  • 30,707
  • sudo hostname newname will change the hostname to newname. You don't need to edit the hostname and hosts files to do so. This also doesn't mean the router will use it as the name. That depends on the router itself. – dobey Apr 22 '16 at 14:46