HowTo: Configure Ubuntu to be able to use and respond to NetBIOS hostname queries like Windows does
Users in the Windows world are very used to referencing PC’s via their NetBIOS names instead of their IP address. If your PC has a dynamic IP address (DHCP-assigned) of 192.168.0.12 and its hostname (computer name) is “gordon”, Windows users can happily jump into a command line or an Explorer window and ping the name “gordon” which will magically resolve to 192.168.0.12.
If your host is not configured with a Hosts file entry on your local PC or a DNS entry to associate a name with an IP address, Ubuntu can only use the IP address of that PC to communicate with it which means you have to remember what that IP address is with your feeble grey-matter in your head. Likewise, Ubuntu will not respond to a Windows PC pinging its NetBIOS name because Ubuntu does not use NetBIOS at all by default and so it will ignore such requests.
So how do we get Ubuntu to resolve NetBIOS names like Windows? And how can we allow Windows to ping Ubuntu like another Windows PC? Read on…
Let’s illustrate the problem first. You’ll need a Windows PC on your network to test this. For this article, the Ubuntu PC will be called “gordon” and the Windows PC will be called “alyx”.
On either PC, if you open a terminal or Command Line window and ping the opposing machine, eg:
$ ping alyx
C:\> ping gordon
You get an error stating that the host cannot be found. Now in the case of Windows, if you were to ping another Windows PC instead of an Ubuntu PC, you can ping its name with no problem.
Let’s sort this out, shall we?
Allowing Ubuntu to ping Windows NetBIOS names
Ubuntu is setup for Linux use, not Windows use, so we need to install a package that will allow Ubuntu to more readily mix in with Windows networks and use NetBIOS. This package is called “winbind”.
- Open a terminal and type in the following at the terminal prompt:
$ sudo apt-get install winbind
- Once installed, we need to tell Ubuntu to use WINS (as provided by winbind) to resolve host names. Type in:
$ sudo gedit /etc/nsswitch.conf
…which will open the file into the Gnome Editor.
- Scroll down to the line that starts with “hosts:”. In Ubuntu Jaunty, it looks similar to this:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
- Add the word “wins” on the end of this line such that is now looks like:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 wins
- Save and exit the editor.
- Now let’s ping the name of our Windows box again.
$ ping alyx
…and it now resolves!
- Pat yourself on the back.
Allowing Windows to ping Ubuntu NetBIOS names
This is just one half of the equation. We now need to allow Windows to be able to ping Ubuntu PC’s using its NetBIOS name. This requires Ubuntu to recognise and respond to that request. We need to setup a server daemon to do this. In Ubuntu, this particular server daemon is called Samba.
- Installing Samba is simplicity itself. Open a terminal and type in:
$ sudo apt-get install samba
- Once that has finished, your Ubuntu PC will automagically respond to all NetBIOS queries for its hostname straight away, and that’s not just from Windows machines, but other Ubuntu machines (configured with the “winbind” package) as well.
- Pat yourself on the back again.
Leave a Reply