Saturday, July 30, 2016

How to access samba share in linux by hostname from a windows machine

Hello ...

I believe many of you out there are looking for an answer to this problem, when you have a Linux machine and install samba, your folders are accessible from a windows machine using the IP address but not via the host name.

Follow the below only if your share is accessible via IP and if you are able to ping your linux host name from a windows system with the following command

    ping hostname.local

do you notice an IPv6 address in your response?

The cause of this problem is because your Linux machine associates its host name to the IPv6 address instead of the IPv4 address, whereas Samba binds to the IPv4 protocol


So lets disable IPv6 on your linux machine using the below steps.

1) Open Terminal
2) Enter sudo gedit /etc/sysctl.conf and open the configuration file and add the following lines at the end
            net.ipv6.conf.all.disable_ipv6 = 1
            net.ipv6.conf.default.disable_ipv6 = 1
            net.ipv6.conf.lo.disable_ipv6 = 1

3) After that run $ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

     If it reports ‘1′ means you have disabled IPV6. If it reports ‘0‘ then please follow Step 4 and Step 5.

4) Type command sudo sysctl -p you will see this in terminal.

             net.ipv6.conf.all.disable_ipv6 = 1
             net.ipv6.conf.default.disable_ipv6 = 1
             net.ipv6.conf.lo.disable_ipv6 = 1

5) Repeat above “Step 3” and it will now report 1.


after completing the above steps, ping your hostname.local again from a windows machine, see if an IPv4 address is shown in the response. Access your share using the same \\hostname.local\


Let me know in the comments section below if this works for you.

2 comments:

  1. Thank you. Dynamic IPv6 prefixes, as given to many customers here in Germany, are prediciting malfunctions with Samba. Disabling IPv6 on my storage server is a little bit like going back in time, but solves the issue. Thank you for this idea.

    ReplyDelete
  2. Hi. Many thanks for this. Windows 7 connecting to Raspberry Pi (Raspbian Jessie OS VERSION_ID = 8 ID_LIKE=debian) was reporting an IPv6 address when using Windows command:
    ping raspberrypi.local
    Made the suggested changes on Pi and Windows now reporting IPv4 IP address.

    ReplyDelete