You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何仅通过主机名而非hostname.local访问Ubuntu Server

Troubleshooting Bare Hostname Resolution for Ubuntu Server 16.04 LTS

Hey there, let's work through this hostname issue together. Since you can reach ubuntuserver via its IP and ubuntuserver.local (which relies on mDNS/Avahi), but not just the bare ubuntuserver hostname, here are targeted fixes based on your multi-OS setup:

1. Fix Windows Hosts (firstwin/secondwin) Resolution

Windows uses NetBIOS/WINS or LLMNR to resolve bare hostnames by default, and Ubuntu Server 16.04 doesn't include the required Samba components out of the box to respond to these queries.

  • Install the necessary packages:
    sudo apt-get update && sudo apt-get install samba winbind
    
  • Restart the NetBIOS name service to apply changes:
    sudo systemctl restart nmbd
    

After this, your Windows machines should be able to resolve ubuntuserver directly using the bare hostname.

2. Fix Ubuntu Desktop (ubuntudesktop) Resolution

Ubuntu 17.10 typically uses systemd-resolved which supports LLMNR (Link-Local Multicast Name Resolution) for local hostname resolution. Let's ensure your server has LLMNR enabled:

  • Edit the systemd-resolved config file:
    sudo nano /etc/systemd/resolved.conf
    
  • Find the LLMNR line, uncomment it, and set it to yes:
    LLMNR=yes
    
  • Save the file (Ctrl+O, Enter) and exit (Ctrl+X), then restart the service:
    sudo systemctl restart systemd-resolved
    

If that doesn't work, check if your local router supports DHCP-based DNS registration. Ensure your server sends its hostname to the DHCP server:

  • Edit the DHCP client config:
    sudo nano /etc/dhcp/dhclient.conf
    
  • Make sure this line exists (uncomment if needed):
    send host-name "ubuntuserver";
    
  • Restart networking to apply:
    sudo systemctl restart networking
    

3. Double-Check Hosts File Details

Even though you mentioned your hosts file is correct, it's worth verifying the server's /etc/hosts has a line mapping its local IP to the hostname, like:

192.168.x.y    ubuntuserver

This ensures the server recognizes its own hostname locally, which can help with some resolution flows.

4. Test to Diagnose Further

If the above fixes don't work, run these tests to narrow down the issue:

  • On ubuntudesktop, run dig ubuntuserver or nslookup ubuntuserver to see if a DNS server is returning an IP. If you get NXDOMAIN, DNS isn't resolving the hostname.
  • On a Windows machine, run nbtstat -A <ubuntuserver-IP> — if you see ubuntuserver listed, the NetBIOS service is working; if not, recheck the Samba installation.

内容的提问来源于stack exchange,提问作者alculete

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:33:28