Question One PC cannot access my Pi server using the SAMBA name ?

Minaz

Reputable
Sep 20, 2021
136
4
4,585
I was doing a large file transfer from my main PC to my Pi server and saw that it was taking an unusually long time. Checking the Pi server, I figured the reason was that it was trying to transfer the file using the WiFi connection. So I disabled WiFi on the Pi server hoping that it would make the connection using ethernet. However, once I did that, it would no longer recognize the Pi server using the SAMBA name i.e. \\SERVERNAME. It would still connect using the ethernet IP address i.e. \\192.168.1.xxx. If I reconnnect WiFi, then it would connect to the server again using \\SERVERNAME (presumably through WiFi).

Trying out another PC on the same network, it could connect to the Pi server using either \\SERVERNAME or the IP address. Also, Pi recognized itself if asked it to ping \\SERVERNAME (itg would ping 127.0.0.1 successfully).

What is going on and how can I resolve this? My hunch is that my main PC has stored somewhere that \\SERVERNAME is the WiFi connection and did not reset the entry when I disabled the WiFi on my server, is that a possibility, or is something else going on? Either way, what can I do to fix it?
 
More questions than answers:

"So I disabled WiFi on the Pi server hoping that it would make the connection using ethernet".

Was the Pi server connected wirelessly and wired at the same time? I would expect one or the other - not both at the same time.

Used wired connectivity and ensure that the Pi Servers wifi is disabled.

Ethernet IP address "192.168.1.xxx". Static or DHCP address? I would expect a Static IP address outside of the allowed DHCP IP address range and reserved for the Pi server via the Pi server's MAC.

(Note: no need to redact 192.168.1.xxx IP addresses. Those addresses are used by thousands of small networks.)

FYI:

https://www.lifewire.com/what-is-a-private-ip-address-2625970

Also note the paragraph regarding Reserved IP addresses and 127.0.0.1
 
  • Like
Reactions: Minaz
I always use the IP addresses. The microsoft name stuff seems to always have some strange random issues for me.

Someplace that I have never found microsoft has a mapping of that name to some ip address.

You might be using different IP on wifi and ethernet. They use different mac addresses....so that may also make a difference.
 
  • Like
Reactions: Minaz
Yes, sorry I should have been more specific. I had both WiFi and ethernet connected at the same time, but did not know (or perhaps forgot) that I had done that.
The ethernet has a static IP address, and it is 192.168.1.126, same as it had always been since the Pi server was setup.

I have no idea what the WiFI IP address was before I disconnected it, I did not check.
This is why, I am thinking that maybe for example the WiFi might have had say 192.168.1.135 (or whatever) and maybe Windows had mapped:

PISERVER ==> 192.168.1.135 on my PC client side somewhere

I do not think the problem is on the server side since other PCs are not having this problem (to double check, I just tried doing this on my wife computer, and she could connect using \\PISERVER just fine). Also, previously, my main PC also could connect using \\PISERVER.

I did try adding netbios name=PISERVER in smb.conf on the server side but it made no difference.
Also, /etc/hostname has the correct entry (PISERVER).

I do agree that IP address is more reliable, in fact that is how I usually troubleshoot these things when the SAMBA mapping isn't working (like now). The reason I use SAMBA names is a) laziness to not have to keep typing out the whole IP address, and b) in case one day if I have to change my server IP address for any reason, I don't have to rewrite all my backup scripts to reflect the new address.
 
Last edited:
The problem you are having is your PISERVER didnt properly register its wired ip with your DNS server (probably your router). It only registered it's WiFI ip.
You can manually force a mapping in windows for a name to ip. The only problem with doing this is if the ip ever changes, your mapping gets broken.

The file is "c:\windows\system32\drivers\etc\hosts"

edit the file with notepad as an administrator, the easiest way I find to do this is to run a cmd prompt as administrator, cd into "c:\windows\system32\drivers\etc" then type
"notepad hosts"
add 1 line to it
192.168.1.135 PISERVER
and save it, then try to ping again. (change that ip if I got it wrong)
 
  • Like
Reactions: Minaz
Clarify:

"The ethernet has a static IP address, and it is 192.168.1.126, same as it had always been since the Pi server was setup".

[My underline.] Did you mean to type "PISERVER"?

Meaning that PISERVER was configured to be 192.168.1.126? Or is PISERVER DHCP and currently being given 192.168.1.135 by the router? And thus the IP address subject to being changed.

= = = =

On the router reserve a static IP address for PISERVER via PISERVER's MAC. Use an IP address outside of the DHCP IP address range allowed to the router. You must be careful not to duplicate any Static IP addresses already assigned and in use.

Then refer directly to PISERVER in your script files.
 
  • Like
Reactions: Minaz
The problem you are having is your PISERVER didnt properly register its wired ip with your DNS server (probably your router). It only registered it's WiFI ip.
You can manually force a mapping in windows for a name to ip. The only problem with doing this is if the ip ever changes, your mapping gets broken.

The file is "c:\windows\system32\drivers\etc\hosts"

edit the file with notepad as an administrator, the easiest way I find to do this is to run a cmd prompt as administrator, cd into "c:\windows\system32\drivers\etc" then type
"notepad hosts"
add 1 line to it
192.168.1.135 PISERVER
and save it, then try to ping again. (change that ip if I got it wrong)
This solved the problem, thank you. So it appears that as you say, it is a DNS server issue. I really don't mess with my router (it is supplied by Chartered Spectrum and is quite locked down honestly, but there are a few things I can do with it, but I seldom touch it). That being said. would there have also been a "proper" solution to this to get the Pi server to broadcast the correct IP address/hostname pair to the router (now using the ethernet connection)?
 
Clarify:

"The ethernet has a static IP address, and it is 192.168.1.126, same as it had always been since the Pi server was setup".

[My underline.] Did you mean to type "PISERVER"?

Meaning that PISERVER was configured to be 192.168.1.126? Or is PISERVER DHCP and currently being given 192.168.1.135 by the router? And thus the IP address subject to being changed.

= = = =

On the router reserve a static IP address for PISERVER via PISERVER's MAC. Use an IP address outside of the DHCP IP address range allowed to the router. You must be careful not to duplicate any Static IP addresses already assigned and in use.

Then refer directly to PISERVER in your script files.
When I first setup my Pi, I setup ethernet (eth0) and assigned a static IP to it (192.168.1.126).

Then I setup SAMBA and assigned the Pi the hostname of PISERVER.
At this point everything was working.

Later, WiFi was added, I am guessing this was due to a period where I was messing around with settings and did not realize that this could cause the Pi server to assign PISERVER to whatever the WiFi IP address was (I just put 192.168.1.135 a placeholder bec I did not check what this IP was - it could have been any address).
At this point, file transfers slowed to a crawl which made me suspect that the traffic was being routed to the WiFi when using the PISERVER network name (but not when I was using the direct IP address of 192.168.1.125 presumably).

To test this hypothesis, I disabled WiFi on the Pi server, and this confirmed my suspicion because the PISERVER hostname became unresolved.

I guess this is a long way of answering that I do not think that DHCP would have had any effect on the ethernet IP address, although of course the WiFi would have been assigend since I did not assign it manually.
 
So I maybe not 100% correct on this since i have limited knowledge in how microsoft does file sharing in a small network.
So the way it finds these shares on your local network is not actually DNS. It sends out a special broadcast message asking machine on the network to tell it their share names. It then stores this in a cache table in memory. I think this is using what is called WINS which has a similar purpose to DNS but is not actually DNS.

If nothing responds it then uses DNS. Since you also don't have a actual local DNS server it will also look in the HOSTS file.
It then finally tries a actual DNS server on the internet which of course does not have your local machine.

So the only way to get this to work automatically is for this magic microsoft broadcast message to put the name in the cache table. Now if you want to get very ambitious and run a actual DNS server it is possible to have it also run the DHCP function. That way when ever it gives out a IP it also maps a name to the new IP address.

I have always been frustrated by this feature and always use IP addresses. I also tend to run static IP on almost all my machines so they never change.
 
  • Like
Reactions: Minaz