Windows 10 Hosts file alias not working with file share

hosts-filenetwork-sharewindows

I am working on a project that requires that I have an alias in my hosts file that maps \\share to localhost. I added this line "127.0.0.1 localhost share" to my hosts file, and when I ping share, I get a response from localhost so I know that the alias is working. I have some locally shared folders that I can access through the Windows File Explorer when I access \\localhost\dir1, but when I type \\share\dir1, I get a prompt asking for me to enter network credentials. None of my network credentials work, and I am unable to access \\share. I did some research and determined that I can go into Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings and disable password requirements, although I am on a domain that has restricted this option. Is there any other way that I can access \\share\dir1 without requiring a username and password?

Best Answer

I'm guessing this is a result of SMB using NETBIOS; it listens with an SNP of IP and FQDN. Your alias is essentially unknown to SMB.

You could try either 1) using netdom to add an alternate name, or 2) disable NETBIOS over TCP, which forces SMB direct hosting

Additional reading: https://support.microsoft.com/en-us/help/3181029/smb-file-server-share-access-is-unsuccessful-through-dns-cname-alias

https://support.microsoft.com/en-us/help/204279/direct-hosting-of-smb-over-tcp-ip