Windows browsers often fail to resolve Ubuntu hostnames because Windows relies on NetBIOS and WINS for local name resolution, while Ubuntu uses mDNS (Bonjour). To fix this, you must install the nmbd service from the samba-common-bin package on Ubuntu. This enables SMB/CIFS name broadcasting that Windows machines can understand natively without additional configuration.
Understanding the Resolution Gap
When you type a hostname like lenovo into the Windows address bar or run command prompt, Windows does not automatically query DNS servers for local LAN names unless they are explicitly configured in your network profile. Instead, it attempts to resolve the name via several legacy methods. The primary method is NetBIOS over TCP/IP, which requires a server to broadcast its name on the local subnet. Ubuntu, by default, runs systemd-resolved which handles standard DNS queries but does not participate in NetBIOS name broadcasts. Consequently, the Windows machine sends out a NetBIOS name query, receives no reply from the Ubuntu server, and displays an error such as "This site can't be reached" or "DNS_PROBE_FINISHED_NXDOMAIN".
This issue is distinct from general internet connectivity problems. Your home server is likely accessible via IP address (e.g., http://192.168.1.50), proving that the HTTP services are running and the network path is valid. The failure is strictly at the name-to-IP translation layer. While modern Windows versions support mDNS (Zeroconf) if the Bonjour service is installed, most consumer installations do not include this by default. Therefore, relying on mDNS alone is risky. The most robust solution is to make the Ubuntu server speak the language Windows expects: NetBIOS.
Installing Samba Components on Ubuntu
The core tool needed to solve this is nmbd, the NetBIOS name server daemon included in the Samba suite. You do not need to configure Samba shares necessarily, but you do need the background service that advertises the computer's name on the network. Begin by updating your package lists to ensure you have the latest definitions. Open a terminal on your Ubuntu server and execute the following command with sudo privileges:
sudo apt update
sudo apt install samba-common-bin
During installation, you may be prompted to confirm the disk space usage. Press 'Y' to proceed. This package installs nmbd, smbd, and related utilities. Once installed, the system should automatically start the nmbd service if it is part of the standard Samba installation group. However, in minimal Ubuntu Server installations, services might not start automatically upon first package installation. You should verify the status of the service immediately after installation.
Verifying Service Status
Check if the NetBIOS name daemon is active by running:
systemctl status nmbd
If the service is inactive or failed, enable and start it using:
sudo systemctl enable nmbd
sudo systemctl start nmbd
You can also check if the service is listening on UDP port 137, which is the standard port for NetBIOS name services. Use the ss command to verify:
ss -uln | grep 137
If you see output indicating :137 is bound, the service is correctly advertising your hostname. If the output is empty, there may be a firewall rule blocking the traffic or a misconfiguration in the systemd unit file.
Configuring Firewall Rules
Ubuntu Server typically comes with ufw (Uncomplicated Firewall) enabled. Even if nmbd is running, UFW will block incoming NetBIOS broadcasts if not explicitly allowed. You need to permit traffic on ports 137 and 138 (UDP) and optionally 139 (TCP) for NetBIOS session services. Add these rules using the following commands:
sudo ufw allow 137/udp
sudo ufw allow 138/udp
sudo ufw allow 139/tcp
After adding the rules, reload the firewall to ensure changes take effect:
sudo ufw reload
It is important to note that allowing these ports exposes your machine to local network discovery protocols. In a trusted home LAN environment, this is standard practice. If you are concerned about security, ensure your router isolates guest networks from the main LAN where the server resides.
Testing Name Resolution on Windows
Once the service is running and the firewall is configured, you must clear any cached negative resolutions on the Windows client. Windows caches failed DNS lookups for a short period. Open the Command Prompt on your Windows machine and flush the DNS cache:
ipconfig /flushdns
Next, attempt to ping the hostname to see if it resolves to the correct IP address:
ping lenovo
If the ping returns replies with the correct IP address of your Ubuntu server, the name resolution is working. You can now open your browser and navigate to http://lenovo or http://lenovo.local (if mDNS is also working). If it still fails, try accessing it via the full NetBIOS name format, though this is rarely necessary on modern networks.
Alternative: Using .local Domain
If you prefer not to use Samba/NetBIOS, you can rely on mDNS. Ensure the avahi-daemon is installed and running on Ubuntu:
sudo apt install avahi-daemon
sudo systemctl enable --now avahi-daemon
Then, access the server using the .local suffix, e.g., http://lenovo.local. This requires the Windows machine to support mDNS, which Windows 10 and 11 handle better than older versions, but it is less universally reliable than NetBIOS in mixed environments. For pure simplicity in a Windows-heavy office, the Samba approach remains the gold standard.
Frequently Asked Questions
Why does my Windows PC work with IP but not hostname?
This confirms that network connectivity is fine but name resolution is failing. Windows defaults to NetBIOS for local names rather than DNS, so your Ubuntu server must advertise its name via NetBIOS protocols, which standard DNS resolvers do not handle.
Is it safe to leave Samba installed if I don't share files?
Yes, installing samba-common-bin primarily gives you the nmbd service for name resolution. You do not need to configure smb.conf to share directories. The service runs passively to answer name queries and poses minimal risk if your firewall restricts access to the local subnet only.
What if ping works but the browser still fails?
If ping resolves the IP, the browser issue might be due to HTTP vs HTTPS mismatches or firewall blocking port 80/443. Ensure your Ubuntu web server is actually listening on those ports and that UFW allows inbound traffic on ports 80 and 443.
Can I use a different Linux distribution with the same fix?
Yes, most Linux distributions support Samba or Avahi. On Debian-based systems, the commands are identical. On RHEL/CentOS, you would use yum install samba-common-tools and manage services with systemctl. The underlying principle of enabling NetBIOS or mDNS remains the same across platforms.
How do I disable NetBIOS if I change my mind?
To stop advertising your name via NetBIOS, simply stop and disable the nmbd service using sudo systemctl disable --now nmbd. You will then need to rely on mDNS (.local) or static entries in the Windows hosts file for name resolution.