Unable to resolve Windows LAN hostnames

After doing a fresh DietPi v102 install, I’m unable to resolve other machines hostnames.
Raspberry Pi 2
Connected through lan
DHCP (static ip given by router)
Other machines are windows machines.
Ping from windows machine to rp hostname works, ping from rp to hostname of windows machine does not.
Ping from rp to LAN ip works, ping from rp to external domain works.

In the past I’ve been using an older version of DietPi and never had any issues with this.

Any help is appriciated

Hi Mattie,

This may be linked to:https://github.com/Fourdee/DietPi/issues/135 which has been resolved for v103.

For now, can you please try the following:

apt-get install resolvconf -y
reboot

Let me know if you are still unable to ping your Windows systems.

I did that, but it stated it was only for static config.

I posted my question after a lot of googling, but appearantly not enough…
I solved it by installing winbinds and adding wins to the hosts entry of /etc/nsswitch.conf

Resolvconf will update your DNS records when using DHCP.

I posted my question after a lot of googling, but appearantly not enough…
I solved it by installing winbinds and adding wins to the hosts entry of /etc/nsswitch.conf

Intresting. Thanks for sharing.
I was thinking about adding this as default to DietPi systems, but winbinds is a big installation 49mb~ with lots of dependencies.

Did previous installations have winbinds included? I can’t remember adding it myself last time i set up this server (more than 6 months ago)

HI Mattie,

winbinds has never been installed on any DietPi systems/images. It may be pulled in with another package, samba fileserver/client?

Ok, i just did a test to see if the bugfix for 103 solved it.
I rewrote 102 wheezy, it auto updates to 103. After that windows hostnames are still not found, so i assume installing winbounds is the only way.
HOWEVER, on 103 it doesnt resolve any hostnames anymore, so apt-get update failes (and so does the internet test in dietpi-software).
This was never the case in v102. It looks like with DHCP it doesnt use the gateway as dns.

Is there any way to install 102 and not let it auto update to 103? When i had 102 set up and manually added the resolveconf package i had no issues.

Hi Mattie,

The update is automatic. It can be prevented (a cheeky hack) but will require you to change the following file after writing the image:

#Change to file contents below from 102 to 1000
/boot/dietpi/.version

Ideally, I’d like to see the contents of your resolv.conf and network config so we can find the cause. Please paste the following results:

cat /etc/resolv.conf
cat /etc/network/interfaces

Well i tried to check the resolv.conf as well and it didnt exist. When i manually added resolvconf package to 102 it did:

root@rp-server:~# cat /etc/resolv.conf
cat: /etc/resolv.conf: Not a directory

root@rp-server:~# cat /etc/network/interfaces
#/etc/network/interfaces

# Local
auto lo
iface lo inet loopback

# Ethernet
auto eth0
iface eth0 inet dhcp
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.202
dns-nameservers

# Wifi
#auto wlan0
iface wlan0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.202
wireless-essid FuzonWifi
wireless-key abcde12345
wireless-mode Managed
wireless-power off
wpa-ssid FuzonWifi
wpa-psk abcde12345
dns-nameservers

Thanks Mattie,

resolvconf is installed and configured with the v103 update, at least, it should be :slight_smile: I’am eager to find out why your system has issues with v103.

Is there any chance you could test a fresh install of DietPi, let it update to v103, go through the install process. Once the system is installed, rebooted and ready, run these commands again:

cat /etc/resolv.conf
cat /etc/network/interfaces

I installed fresh, and exited the dietpi-software that auto-launches after the 103 update:

root@DietPi:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 84.116.46.22
nameserver 84.116.46.23

#/etc/network/interfaces

# Local
auto lo
iface lo inet loopback

# Ethernet
auto eth0
iface eth0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4

# Wifi
#auto wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid FuzonWifi
wireless-key abcde12345
wireless-mode Managed
wireless-power off
wpa-ssid FuzonWifi
wpa-psk abcde12345
#dns-nameservers 8.8.8.8 8.8.4.4

These look much better, I will continue to do what i normally do in order to see at what point it goes wrong

Ok, after that I did a reboot and the setup resumed with a message that i had no internet connection.
Checking resolv.conf again and it was gone again.

Thanks Mattie,

Looks like an possible issue with your router and DHCP.
The router is giving an external IP of 84.116.46.22 for DNS, instead of its own IP address. This is why you can’t ping local machines because your router is forcing your device to resolve DNS outside your local network.
As for why resolv.conf is empty after the 2nd reboot, no idea. I tested on my own network to verify, works everytime.

The only thing I can suggest to resolve this issue is use a static IP address on your device, which allows us to define DNS server:

  • run dietpi-config
  • networking options
  • select ethernet
  • select " Copy Copy Current address to Static"
  • change “Static DNS” to match your Static Gateway address.
  • Apply settings “Save Changes”.

Now try to run your ping tests.

In windows all my machines automatically get the routers ip as dns… in dietpi i get the google dns, which i have not configured anywhere myself.
As for the nameserver part, I don’t think it’s a router “issue”, more of a feature… My router does not support naming devices, so pinging hostnames is purely based on windows netbios, hence the need for wins.

As for the resolv.conf going missing… I just tested it with dietpi v94 and it remains after reboot, as it also did on my v102, after installing it manually. Must still be a change in v103 that causes it I guess?

Assuming your talking about resolv.conf, thats because resolvconf was not installed prior to v103. Resolv.conf was never being updated. This was a “bug” in DietPi. Its a miracle that this “bug” was actually giving you a “fix” :slight_smile:

I just checked the patch code. If you had DHCP active during the patch, the only trigger is:

apt-get install resolvconf -y

As this is exactly the same as what you did, it doesn’t appear to be an issue with the patch.

I don’t think it’s a router “issue”, more of a feature… My router does not support naming devices

If thats the case, you should consider using static IP’s instead of hostnames.

No i meant in my interfaces. I don’t know where they are from other than they are preset in dietpi?
I assumed it had something to do with the new feature of 103 to set static dns now as well.
What creates the resolv.conf prior to this fix? As in v94 I had the correct nameservers in resolv.conf as well.

I set static leases in my router, but use the hostnames for everything. I do not mind installing winbinds to get that working.

Would a fix for me be uninstalling resolvconf after installing 103, and manually setting the vallues in that file?

I’m very new to linux and everything i do is stitching together different tutorials on internet.
I fail to understand what the differences are with having dns entries on the interface, and the use of the resolv.conf file.

(On another note, I’m having a new router for chrismass, which might also solve all these issues :stuck_out_tongue:)

The dns-nameserver will be commented out with a hash at the start (# which means disabled) for DHCP. DietPi-Config > Networking will do this automatically for you when using it to setup network.

Would a fix for me be uninstalling resolvconf after installing 103, and manually setting the vallues in that file?

Yep, that would work for /etc/resolv.conf. If you are running Jessie, you could try disable/enable the service:

systemctl disable resolvconf

EDIT: Ideally, its better practice to just set dns-nameserver in /etc/network/interfaces. This will override resolv.conf
For ethernet with DHCP:

# Ethernet
auto eth0
iface eth0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
#The below is google DNS nameservers. Put a hash sign before dns-nameservers to disable
dns-nameservers 8.8.8.8 8.8.4.4

Reboot system once done.


I’m very new to linux and everything i do is stitching together different tutorials on internet.
I fail to understand what the differences are with having dns entries on the interface, and the use of the resolv.conf file.

When you are running DHCP:
The IP entries in /etc/network/interfaces are ignored. Resolv.conf is then updated with the DNS server it pulled from your router. You can override the resolv.conf values by enabling dns-nameserver in /etc/network/interfaces

If your running STATIC IP
All the IP settings from /etc/network/interfaces will be used. Resolv.conf is no longer used. dns-nameserver value from /etc/network/interfaces will be used, and, must be enabled.

(On another note, I’m having a new router for chrismass, which might also solve all these issues > :stuck_out_tongue:> )

Hopefully it should, depends on which one santa is going to give you. Just dont be naughty or you’ll end up with a coal powered router. I’ve had coal powered stuff in the past :smiley:

Thanks for all the help so far, I will try those solutions, see what i like best.
Perhaps switch to jessie as i want to use the let’s encrypt stuff as well.

As for the router, it will be a TP-Link TL-WR1043ND

cheers