Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Ubuntu Server 20.04.3 Static IP hostname not resolving in Lan

Writer Olivia Zamora

What is working:

  • Internet access
  • The configured Static IP
  • Pinging other machines in Lan (IP and hostname)

What I'm trying to solve:

I can't ping/ssh etc. the Ubuntu server from other clients using the hostname. IP works fine.

I have an AVM Fritz Box router acting as the DHCP/DNS server. It took a few days for my Windows 10 machine to be available via hostname, I thought it would be the same with the server, but it's been a week and still nothing.

The router displays the hostname in the gui.

Upon installation I chose DHCP, I could reach the server using the hostname, it stopped working when I switched to static IP.

/etc/netplan/00-installer-config.yaml:

# This is the network config written by 'subiquity'
network: renderer: networkd ethernets: enp2s0: dhcp4: false dhcp6: false version: 2 bridges: br0: interfaces: [enp2s0] addresses: - 192.168.1.4/24 gateway4: 192.168.1.1 nameservers: addresses: - 192.168.1.1 search: - fritz.box dhcp4: no dhcp6: no

I am using LXD containers, that's why I need the bridge. But it wasn't working even before I added br0.

What I tried:

  • Messing around with systemd-resolvedI disabled it, as suggested somewhere, didn't work. Tried to force 192.168.1.1 into /etc/resolv.conf, also didn't work.
  • I recently installed PiHole in a container, configured the router to redirect all DNS requests to it and it's working well, from what I can tell. I tried adding a manual DNS record via the PiHole gui, still nothing. Tried adding the server IP manually to /etc/hosts in the PiHole container... nothing.
  • I installed another Ubuntu Server instance in a VM, configuring static IP within the installer and comparing the config files (at least the ones I know about). That's where I got the search: line in the netplan yaml file from, unfortunately not much else.

Pinging my Windows 10 PC, which is also configured with a static IP (ping pc-hostname) comes back as 192.168.1.2 pc-hostname.fritz.box.

It's really hard to get info on this. Methods of configuring static IP differ a lot between releases, even between server and desktop of the same release. From the few articles and blog posts I've found with the 20.04 netplan method, none of them appear to do things differently.

Edit:

IPs:

fritz.box 192.168.1.1
ubuntuserver 192.168.1.4
Win10 192.168.1.2
PiHole 192.168.1.5

3 Answers

So there's a lot going on here. First, check your DNS configuration.

$ nslookup
> server 182.168.1.1
Default server: 192.168.1.1
Address: 192.168.1.1#53
> 192.168.1.4
< Here you will probably get an error >

The code example above looks a litte funky, but you are going to want to type nslookup, then "server 192.168.1.1", then the IP of the host you want to query. In this example I picked IPs that you used. The error should come from the DNS entry not being configured.

To configure your DNS, you can probably do two things.

  1. Use DHCP, that will likely cause your router to associate your requested name with a DNS entry on your LAN. use "hostnamectl set-hostname yourname" to set your desired hostname.
  2. Log into your router and create a static entry for the IP address.

I hope that helps!

2

Ok I finally figured it out, I had to enable MulticastDNS in /etc/systemd/resolved.conf:

[Resolve]
MulticastDNS=yes
LLMNR=no # You may need to set this as well, not sure

Honestly I'm not sure what combination specifically did it, I set up a Powershell script in the background, which would beep as soon as it could ping the hostname of the Ubuntu server. I was playing around with the config, with the resolvectl utility, changing essentially the same settings as are in this config, just per interface. After I set MulticastDNS the script beeped almost immediately. You will likely need to do a sudo systemctl restart systemd-resolved before it starts working.

Not enough reputation to comment Sergs answer.

With a Fritzbox 7590 and a ubuntu server with static IP, editing/etc/systemd/resolved.conf works:

[Resolve]
MulticastDNS=yes
LLMNR=yes

With this config i can ping the machine with its hostname. In the web frontend of the Fritzbox the hostname of the machine is correct and not PC-192-168-178-XX.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy