I have a CIFS share working correctly in fstab using

//192.168.x.x/directory/to/folder /media/my/directory cifs ...

However since our company network dynamically allocates ip addresses, is there a way to mount a CIFS folder using something like:

//mypc.servername.local/directory/to/folder /media/my/directory cifs ...

So that even if the computer's IP address gets changed, the Pi can still access the drive?

  • 1
    Simple answer: Yes. – Huczu Jun 23 '16 at 10:06
  • @Huczu Excellent, can you send me a link or write something to elaborate how? – Pingk Jun 23 '16 at 10:18
  • 2
    But you got it. Use hostname/servername instead of ip address, but network should be configured. More information at: unix.stackexchange.com/questions/16890/… – Huczu Jun 23 '16 at 10:31
  • @Huczu Turns out the samba config file wasn't correct (see my answer) – Pingk Jun 23 '16 at 11:47

The cleanest way is to setup or reconfigure the existing DNS server on your company network. You need to instruct your company DHCP server to point to aforementioned DNS server.

A competent Windows admin will know how to do this easily with Windows Server.

Most cheap SOHO routers should have an easy way to to do this via web-interface too. Some even manage the "fake" .local TLD by default ! Sadly ISPs often hide router manuals or rebrand COTS routers in a confusing way. If you get stuck persitence in the search for manuals will be needed.

Alternatively , dnsmasq is both a DHCP and DNS server for Linux and makes this very easy. You can even run it on a Raspberry Pi !


| improve this answer | |

It turns out our Windows server doesn't use wins, while the samba.conf file by default has wins enabled.

The settings we changed were as follows:

wins support = no
# wins server = w.x.y.z
dns proxy = yes

Then remounting using //mypc.servername.local/... in fstab worked correctly.

| improve this answer | |
  • You probably need to ensure Avahi is installed for mDNS. The Windows DHCP or DNS server is probably set to "Register DHCP leases in DNS". – jww Dec 12 '19 at 10:22
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Dec 16 '19 at 1:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.