Score:3

DNS names do not resolve when using a local static IP

cr flag

I'm creating a Minecraft server with an old desktop computer (a HP Pavilion) running Ubuntu 22.04 and when trying to set up a local static IP, my DNS appears to stop working entirely. At first, I used netplan to edit the connection details, but as I wasn't confident in editing system files (and I couldn't get it to work!), I just used the Ubuntu GUI for manually setting the IP address.

Before I set the address, I checked my router DHCP range (192.168.1.10-254), which meant I could select 192.168.1.2-9 as my static IP - not 192.168.1.1, as that's my router's IP. I went to Settings and after changing the IPv4 Method to Manual, I set my Address to 192.168.1.5, the Netmask to 255.255.255.0 and the Gateway to 192.168.1.1 - my router address - and I successfully connected, which I verified by going into my router web interface and checking the IP assigned.

Everything seemed fine, so I opened Firefox and attempted a search. When this returned a Server Not Found page, I tried https://1.1.1.1 and it showed up as normal. I tried this with a few other IPs and hostnames, and ran ping in the terminal, but it still failed with hostnames, which pointed to a DNS error. I went back to the Settings, disabled Automatic DNS and tried the 1.1.1.1,1.0.0.1 (Cloudflare) DNS addresses. Still no luck. 8.8.8.8,8.8.4.4 (Google DNS) didn't work either.

After searching the internet, none of the answers I've found can fix the DNS - they all say how to change the servers, and it isn't making a difference. I'm also unsure about the Routes part of the IPv4 settings, so I've left that on Automatic.

I am vaguely new to both Ubuntu Desktop and Ask Ubuntu, so if I'm making a stupid mistake or I need to add more information to the question, just tell me :)

David avatar
cn flag
If you have a closed network then where is the DNS server that the machines can resolve against?
BestCoderBoy avatar
cr flag
@David I don't know much about networks, but I'm connecting to a router with an internet connection and an ISP's DNS server - I'm only setting a static IP so I can port forward safely to that computer only. Even if the router DNS didn't work, though, I thought a Cloudflare or Google DNS would work fine. Would the DNS still work?
Terrance avatar
id flag
In your router you can assign your HP server a reserved IP address, via the MAC address of your HP server, that way it always gets the same IP and you can assign it both inside or outside your DHCP range. Then your server will always get the same IP address and also get the DNS settings, etc as long as the server is set to DHCP. Having a reserved IP in your DHCP range will not cause any IP duplicates as your DHCP server on your router will block that IP address from going to any other device.
David avatar
cn flag
What ever you did to the config has stopped it from finding the DNS. Follow @Terrance suggestion and it will work fine.
BestCoderBoy avatar
cr flag
@Terrance Thanks for the suggestion! I actually came across reserving IPs while trying to find the setting for static IPs in my router settings, but the two ideas never crossed in my head (I was following a tutorial for port forwarding and it told me to use a static IP). I'll try reserving the IP alongside the port forwarding, and if you want to make your comment an answer, I'll accept it!
Score:5
id flag

In your router you can assign your HP server a reserved IP address, via the MAC address of your HP server, that way it always gets the same IP and you can assign it both inside or outside your DHCP range. Then your server will always get the same IP address and also get the DNS settings, etc as long as the server is set to DHCP. Having a reserved IP in your DHCP range will not cause any IP duplicates or conflicts as your DHCP server on your router will block that IP address from going to any other device.

BestCoderBoy avatar
cr flag
Works perfectly. Just tested it out, and everything's working as expected! Thanks again.
Terrance avatar
id flag
@BestCoderBoy No problem! Glad it worked out for you! :)
in flag
I think the issue was that your router tells the clients (your MC server in this case) what DNS to use. So you stopped DHCP meaning that only the local configuration was being used, so you also needed to tell the MC server what DNS servers to use. There are a lot of different ways to do this, but Ubuntu uses systemd-resolved by default (I gather). Output of `resolvectl` would probably have shown where the issue lay.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.