Setup Ubuntu to browse Windows network by hostname

Jack Wallen
Dec 27, 2010
Updated • Jan 16, 2013
Network
|
12

By default, a Ubuntu desktop with Samba installed will be a member of the Windows workgroup named WORKGROUP. Because that machine is a member of WORKGROUP, you would think you could browse and connect to other machines on the same network by hostname. That is not the case. Instead you would still have to locate a machine's IP address in order to connect. This seems to defeat the purpose of Samba and the ability to join a workgroup. To make life easier you need to, after installing Samba, make a fairly straight-forward change that will then allow your machine to see and reach other machines by hostname. Let's see how this is done.

Samba

Naturally you need to have Samba installed on the machine you plan on using. There are a couple of ways to go about this. You can either open up the Ubuntu Software Center, search for Samba, and install Samba. Or you could open up Nautilus, right-click a folder, select Sharing Options, and the follow all of the prompts in order to get Samba correctly installed.

Once Samba is installed you can double check to make sure the Workgroup is correct by opening up the file /etc/samba/smb.conf and looking for the line:

workgroup = WORKGROUP

If you want (or need) to change the workgroup you belong to, change it there. After you make that change, save the file, and restart Samba with the command:

sudo service smbd restart

Firewall

If you happen to use Firestarter, you are going to need to uninstall it and install a different firewalling tool (GUFW is one of my favorites). If you leave Firestarter installed and you reboot your machine (after making this change) your machine very well may not boot. I will say that I have found Firestarter to include a few bugs (such as getting through it with Port 631 - printing) to make removal a good move. GUFW is a GNOME front-end for ufw which is a much more reliable firewalling tool (and just as easy to use).

Final piece

The last piece, before the configuration, is to install winbind. To do this issue the command sudo apt-get install winbind. You will need to enter your sudo password for the installation to complete. Once that is installed, you are ready to configure.

Configuration

The file you need to edit is /etc/nsswitch.conf. In this file you will see a line that looks like:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

You need to edit this line so that it looks like:

hosts: files mdns4_minimal [NOTFOUND=return] wins dns mdns4

Once you have done this, save the file, and restart networking. To restart networking issue the command:

/etc/init.d/networking restart

Taking advantage

Hopefully you know the host names of some of the machines on your network. If so, try to ping one of those machines by name (not IP address). You should get a positive response back. If you do not know the hostname of any machine on your network you can always click Places > Network and then double click on the Windows Network icon. Once in this window you will see the WORKGROUP icon. Double click on that and it should show all of the machines on your network that belong to that same Workgroup. Take one of those names and try to ping it. You should get positive results back.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. Sebastien said on March 15, 2012 at 12:33 pm
    Reply

    Hi,

    for solving web browsing latency simply change nsswitch.conf
    hosts: files mdns4_minimal [NOTFOUND=return] wins dns mdns4 (as proposed in solution)
    with
    hosts: files mdns4_minimal [NOTFOUND=return] dns wins mdns4

    I’m not truly a network system expert but you should avoid to prioritize wins routing upon dns for keeping web browsing efficient… latency & lan extra activity should certainly come from wins ability to serve web resources instead of local & fast dns :D

    doing so will resolve win hostnames as well even if it must pass first through dns where they obviously won’t be found :)

    thanks & have a good day all

  2. Richard said on January 6, 2011 at 11:41 pm
    Reply

    Also, don’t forget that Windows7, by design, does not like to talk with Samba clients on the same network . . . you have to modify security policy. On the Win7 computer, as admin, go into secpol.msc, Local Policies, Security Options, and change Network Security: LAN Manager authentication level and change it to ‘Send LM & NTLM’. I use the 2n option for this that includes NTLMv2 if negotiated. I also set Mininum session security (just a few items down the list) to require 128-bit encryption. This was the only way I could get my Win7 clients talking to my Ubuntu file server consistently and without all sorts of auth problems (for example, I backup to my Ubuntu server and the backup software I use would *not* allow me to use the share on the Ubuntu server until I had made this change).

  3. Ingram said on January 5, 2011 at 10:49 pm
    Reply

    After following these steps on 2 seperate Ubuntu 10.10 systems, I noticed a dramatic slowdown of web pages loading, regardless of the browser used. After removing “wins” from /etc/nsswitch.conf, the slowdown effect went away.

    Any ideas on that?

    1. Bruce said on September 15, 2011 at 3:49 am
      Reply

      After I posted my comment yesterday – I couldn’t let it go – so I kept on trying things and here’s the solution that worked for me:

      1. Install Samba
      2. Install Winbind
      3. In Terminal: sudo gedit apt-get install apache2.2-bin libapache2-mod-dnssd
      4. In System Settings, Samba, Preferences, set Server Settings to work group; in security tab set authentication mode to Share and Guest Account to your login name.
      5. In Terminal: sudo gedit /etc/samba/smb.conf

      uncomment and change this line:

      name resolve order = lmhosts host wins bcast

      to

      name resolve order = lmhosts wins bcast host

      6. reboot

      I can see all of my Windows workgroup machine shared files, they can see my Ubuntu/Samba shared files and Internet is back to speed – Yessss!

      1. Tim K said on April 18, 2012 at 6:41 am
        Reply

        Tried MANY fixes and this worked!! Thank you sooooooo much!!!

      2. nandor said on January 11, 2012 at 11:27 pm
        Reply

        Thanks Bruce!!!

      3. Martin Brinkmann said on September 15, 2011 at 9:33 am
        Reply

        Thanks for posting your solution Bruce, much appreciated.

    2. Bruce said on September 14, 2011 at 5:38 am
      Reply

      I also noticed about a 80% slowdown of web pages loading under Ubuntu 11.04. Just as you noted, removing “wins” from /etc/nsswitch.conf, fixed the problem. I can see my ubuntu shares on my XP machine and they load like a rocket. However I cannot see Windows shares on my Ubuntu machine without the “wins” statement in the /etc/nsswitch.conf file. If you’ve figured this out I’d really appreciate the help. I’m running a cheap quad-core AMD 840 chip with a 2 Tb raid 0 array. The performance is instantaneous (15 second boots!). The Google Chrome browser loads pages faster than I can see – as long as “wins” is not in the /etc/nsswitch.conf file.

      Thanks!

  4. Shon said on December 28, 2010 at 4:04 am
    Reply

    I have also found on a couple distros it helps to do the following:

    add “netbios name = computer-name” just below “workgroup = WORKGROUP” and also after installing winbind I have had to edit the smb.conf file like so:

    find the line that looks like:
    ; name resolve order = lmhosts host wins bcast

    and change it to:
    name resolve order = lmhosts wins bcast host

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.