Monday, May 16, 2011

Hostname Resolution with (K)Ubuntu

An entire home network can be a bit of a challenge to manage, which is part of the reason why I migrated years ago to the Linux world. The number of computers in my house kept increasing and Windoze takes way too much effort to just make useful, so I cheerfully went back to my *nix roots. It took a bit of effort to convert the family to the FOSS concept, but everyone (particularly me) has been quite happy with the conversion.
Though part of having a number of computers on the same network is the ability to manage all of them. For convenience, I prefer to have the machine's hostname accessible from the command line. Among other things, it makes my life easier when I have to do some work on a particular computer. Fortunately Ubuntu comes loaded with samba as part of the default installation.
There is basically only two steps to this. Open the samba configuration file for editing. You can use the command below, or use your own favorite method. That choice is up to you.
sudo nano /etc/samba/smb.conf
Once you have the file open, search for the workgroup line in the configuration file. Which for the version I'm running is on line 38 (I'm running version 3.5.8). The value on the right hand-side of the equal sign should be changed to the same workgroup that you're using for the rest of your home network. Once you're done, save the modified configuration file.
We are fortunate that Ubuntu comes with a working samba client installed, and doubly fortunate because it comes with winbind installed. So the next thing that we are going to do is modify another file.
sudo nano /etc/nsswitch.conf
Here we're looking to add something. Look for the hosts: line and insert wins after the word files, make sure that you leave a space between the words. Save the modified configuration file. Now you can either just restart the machine, or you can restart the services. To restart the services do the following.
sudo service smbd restart
sudo service networking stop; sudo service networking start
The service networking doesn't recognize the restart instruction, so you have to do it with a stop/start sequence. Once all that is done, you should be able to verify operation by doing a ping to the hostname and get a response.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete