ipconfig.co.uk

hostname: see and change the computer name

The Host Name at the top of ipconfig /all is what your computer calls itself, and it is what other devices on the LAN use to find you. Seeing it is one command; changing it differs by platform; understanding why ping laptop works from some machines and not others takes a short detour into name resolution.

See the name

Any shell
hostname                    # Windows, macOS, Linux: the short name
hostname -f                 # Linux/macOS: fully qualified name, if resolvable
hostname -s                 # short name (strip the domain)
hostname -d                 # domain part
hostname -I                 # Linux: all IP addresses (capital i)
hostname -i                 # Linux: the address /etc/hosts maps the name to (often 127.0.1.1; rarely useful)
hostnamectl                 # Linux systemd: static, transient, pretty names and OS info
scutil --get HostName       # macOS: the three names
scutil --get LocalHostName
scutil --get ComputerName
echo %COMPUTERNAME%         # Windows cmd (always upper case)
$env:COMPUTERNAME           # PowerShell
[System.Net.Dns]::GetHostName()
ipconfig /all | findstr /c:"Host Name" /c:"Primary Dns Suffix"
Output
$ hostnamectl
 Static hostname: laptop
       Icon name: computer-laptop
         Chassis: laptop 💻
      Machine ID: 3f2a1b0c8d4e4f6a9b1c2d3e4f5a6b7c
         Boot ID: 9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d
Operating System: Ubuntu 24.04.2 LTS
          Kernel: Linux 6.8.0-45-generic
    Architecture: x86-64

Change it

Windows · PowerShell
Rename-Computer -NewName "steve-laptop" -Restart          # PowerShell, admin; reboot required
# domain-joined:
Rename-Computer -NewName "steve-laptop" -DomainCredential CORP\admin -Restart
Windows · Command Prompt
wmic computersystem where name="%COMPUTERNAME%" call rename name="steve-laptop"   :: legacy; wmic is being removed
sysdm.cpl                                :: GUI: Computer Name tab › Change

Settings › System › About › Rename this PC does the same. Names are up to 15 characters for NetBIOS compatibility (Windows allows longer but truncates for NetBIOS), letters, digits and hyphens only, and take effect after a restart.

Short name, FQDN and DNS suffix

The short name (laptop) plus the domain (home, corp.example.com) is the fully qualified domain name (laptop.corp.example.com). On Windows the domain comes from Active Directory membership (Primary Dns Suffix) or, failing that, from DHCP (Connection-specific DNS Suffix). On Linux hostname -f resolves the short name through /etc/hosts and DNS to find it, which is why it can print an error or localhost on a badly configured machine. The FQDN matters for Kerberos, TLS certificates, mail servers and anything that logs by name; a home laptop can ignore it.

How other devices find you by name

Typing ping laptop can succeed through any of four mechanisms, and which ones are present differs by platform. This is why a name works from a Mac but not from a Windows PC, or works with .local and not without.

MechanismName looks likeWho speaks itNotes
DNSlaptop.home, laptop (with a search suffix)EveryoneWorks only if the router registers DHCP client names in its DNS (many do: Fritz!Box, OpenWrt, pfSense, BT hubs; many do not) or you run a real DNS server
mDNS / Bonjourlaptop.localmacOS and iOS (always), Linux with Avahi (most desktops), Windows 10 1703+ (built in), Android (partly)Multicast on the local segment; no server; the most reliable cross-platform option today
LLMNRlaptopWindows Vista to 11 (being phased out), Linux systemd-resolved (optional)Multicast; Windows-centric; often disabled by security policy because it is spoofable
NetBIOS name serviceLAPTOP (15 chars, upper case)Windows, Samba, some NAS boxesBroadcast on UDP 137; the Node Type and NetBIOS over Tcpip lines in ipconfig /all; legacy
Any shell
ping laptop.local                       # mDNS: works from Mac, Linux with Avahi, Windows 10+
dns-sd -G v4 laptop.local               # macOS: resolve via Bonjour explicitly
avahi-resolve -n laptop.local           # Linux
avahi-browse -art                       # Linux: list everything advertising on mDNS
nbtstat -a LAPTOP                       # Windows: NetBIOS name table of a remote host
nbtstat -n                              # Windows: names this machine has registered
Resolve-DnsName laptop -LlmnrOnly       # PowerShell: test LLMNR alone
Resolve-DnsName laptop -NetbiosOnly
resolvectl query laptop.local           # Linux systemd-resolved (mDNS must be enabled per link)
resolvectl mdns enp3s0 yes

If you want names to work everywhere at home, the two robust choices are: make the router serve DHCP names in DNS (and set a search domain such as home.arpa via DHCP), or rely on .local and make sure Avahi is installed on Linux boxes. Do not use .local as a DNS domain on a server; it collides with mDNS and causes slow or failed lookups.

The hosts file

Every platform consults a local file before DNS: C:\Windows\System32\drivers\etc\hosts (edit as administrator) and /etc/hosts on Unix. One line per mapping: address, then names. It is the right place for a name that must resolve on one machine regardless of DNS, and the first place to look when a name resolves to something surprising.

File
127.0.0.1   localhost
127.0.1.1   laptop.home.arpa laptop        # Debian/Ubuntu convention for the machine's own name
192.168.1.20  printer
192.168.1.10  nas nas.home.arpa
::1         localhost ip6-localhost ip6-loopback

Windows and macOS pick up changes at once (Windows preloads hosts into the DNS cache; run ipconfig /flushdns if it lags). Linux reads it on every lookup. A hosts entry beats DNS, mDNS and LLMNR in the default lookup order on all three.

Where the name shows up on the network

  • The router's client list: the DHCP client sends the hostname in option 12, which is how the router labels your devices. A device that shows as blank or as a MAC address did not send one (many IoT devices) or randomised it.
  • Reverse DNS: the name attached to your address, seen by servers you connect to. On a home connection it is your ISP's generic label, not your hostname.
  • Windows network browsing: computer names in File Explorer › Network come from SMB/WS-Discovery, not from DNS.

Related pages

Last reviewed . Command syntax verified against Windows 11, Ubuntu 24.04, macOS 15 and FreeBSD 14 unless noted otherwise.

Spotted a mistake or a switch we have missed? Every page on this site is written to be checked against real output, so please test on your own machine and compare.