How to enable Samba connections via hostname

Автор: | 07.06.2018

I use Samba quite a bit. Most often I’m working with IP addresses, but there are certain instances where I must set up a network share that is accessible via name. After all, I don’t want to have to instruct end users how to make that connection by opening their file manager and typing smb://192.168.1.208. Instead, I’d rather instruct them to open their file manager, go to the Workgroup, and look for the machine named HIVE2.

But how do you enable this functionality in Samba? Believe it or not, it’s incredibly easy. With a couple of quick edits in your favorite text editor (mine being nano), you can make it significantly easier for users to find Samba shares on your network.

I’m going to demonstrate how this is done. I’ll be doing so on Ubuntu Server 16.04. As networking is handled quite differently in Ubuntu 18.04, I’ll be addressing that particular beast later on. In the meantime, let’s make your trusty Xenial Xerus server Samba shares a bit more user friendly.

SEE: Network security policy (Tech Pro Research)

Configuring Samba

We’re going to make sure the name we use for Samba matches our hostname. There’s one caveat to this. The issue is that if your hostname is longer than 15 characters, you will see errors. If that’s the case, you’ll need to change your server hostname. Issue the command sudo nano /etc/hostname. Check the number of characters in your hostname. If it’s longer than 15, change it, save the file, and reboot the server. If the name is less than 15 characters, you should be good to go. In my case, my Samba server hostname is HIVE2. We’ll set the same name for Samba.

Do note: You don’t have to set the Samba name equal to that of the server hostname. I only do this for simplicity.

With that said, let’s configure.

Open up a terminal window (or log into your Ubuntu Server) and issue the command:

sudo nano /etc/samba/smb.conf

You’ll find the entry:

workgroup = WORKGROUP

You may have already changed WORKGROUP to reflect the workgroup used on your network. Either way, leave that as-is. Under that line, add the following:

netbios name = NAME

Where NAME is the name you want to broadcast for the Samba server. Once you’ve done that, save and close the file.

Restart Samba and nmbd with the commands:

sudo systemctl smbd restart
sudo systemctl nmbd restart

Connecting

At this point, you should be able to open up a file manager (on a machine other than your server) and go to Entire Network | WORKGROUP (Where WORKGROUP is then name of your workgroup). You should see the new name listed (Figure A).

Figure A

Figure A

HIVE2 is my newly renamed Samba server.

That’s all there is to it

And you thought this was going to be challenging. Every so often, there is an issue that can be resolved simply. If you have end users who can’t seem to function when given IP addresses, make this change to your Samba configurations, and make your life (and theirs) a bit more hassle-free.

Also see

Source

Добавить комментарий