Things look quiet here. But I've been doing a lot of blogging at
dan.langille.org because I prefer WordPress now.
Not all my posts there are FreeBSD related.
I am in the midst of migrating The FreeBSD Diary over to WordPress
(and you can read about that here).
Once the migration is completed, I'll move the FreeBSD posts into the
new FreeBSD Diary website.
This article shows you how to use non-standard host names. By default, samba
uses the hostname of the machine on which it is running. In some situations this can
cause a problem.
The problem
Some time ago, I installed samba and recently I
found it wasn't working. I could not see any services from my NT box. So I
went back to my original article and found a reference to the samba diagnostics.
It is frequently difficult to find the DIAGNOSIS.TXT file referred to by so many SAMBA
documents. It seems to move around the website. Hopefully this will settle down. I suggest
trying the following in the order provided:
I started going through that diagnostic document step by step. Things started
failing on step 3:
# smbclient -L fred
No interface found for address 210.55.152.36
Added interface ip=210.55.152.36 bcast=210.55.152.255
nmask=255.255.255.0
startlmhosts: Can't open lmhosts file /usr/local/etc/lmhosts.
Error was No such file or directory
Server time is Sat Jun 12 21:03:45 1999
Timezone is UTC+12.0
Domain=[FAB] OS=[Unix] Server=[Samba 1.9.18p8]
security=share
Server=[FRED] User=[root] Workgroup=[FAB] Domain=[FAB]
Sharename Type Comment
--------- ---- -------
backup Disk Backup directory
ftp Disk ftp server file area
IPC$ IPC IPC Service (Samba 1.9.18p8)
lp Printer local line printer
public Disk public access area
root Disk Home Directories
The first step was to create /usr/local/etc/lmhosts. So I did this:
# touch /usr/local/etc/lmhosts
So onto step 4 of the diagnostics.
# nmblookup -B ducky __SAMBA__
Sending queries to 192.168.0.20
name_query failed to find name __SAMBA__
This tells me that nmbd is incorrectly installed. So I tried starting
it:
# /usr/local/sbin/nmbd -D
Checking the log files I found this:
# tail /var/log/log.nmb
1999/06/12 21:44:59 netbios nameserver version 1.9.18p8 started
Copyright Andrew Tridgell 1994-1997
No interface found for address 210.55.152.36
bind failed on port 137 socket_addr=210.55.152.36
(Can't assign requested address)
make_subnet: Failed to open nmb socket on interface
210.55.152.36 for port 137.
Error was Can't assign requested address
ERROR: Failed when creating subnet lists. Exiting.
I didn't understand that. That IP address didn't belong to my box. It
belonged to my router. So I started composing a message to the questions mailing
list. Then I had an idea. I checked the man pages for nmbd(8).
That's when it struck me: samba is using hostname. DOH! I'll
explain later why this is wrong for me later.
Outdated information
There was another problem with samba. It was holding outdated
information. Here's what I found in another log file:
# tail /var/log/samba/log.smb
Get_Hostbyname(wocker.dvl-software.co.nz):
lookup failureMatchname failed on
wocker.dvl-software.co.nz 192.168.0.99
Get_Hostbyname(wocker.dvl-software.co.nz):
lookup failureMatchname failed on
wocker.dvl-software.co.nz 192.168.0.99
Get_Hostbyname(wocker.dvl-software.co.nz):
lookup failureMatchname failed on
wocker.dvl-software.co.nz 192.168.0.99
Get_Hostbyname(wocker.dvl-software.co.nz):
lookup failureMatchname failed on
wocker.dvl-software.co.nz 192.168.0.99
Get_Hostbyname(wocker.dvl-software.co.nz):
lookup failureMatchname failed on
wocker.dvl-software.co.nz 192.168.0.99
Gethostbyaddr failed for 192.168.0.99
No interface found for address 210.55.210.87
First, this hostname is long out of date. I've not used that hostname for months.
And the IP address 210.55.210.87 was very out of date. My box has a DHCP
connection. The IP address was quite different now. So I killed and restarted samba:
My current topology is rather unusual. If you
look up the hostname of my box, it doesn't match any of the network interfaces connected
to my box. Here's what I mean:
As you can see, neither ed0 nor ed1 matches up to the hostname of
my computer. That is because 210.55.152.36 is my ADSL modem/router. That is
why nmbd cannot open a socket on that address. It's on another device.
[insert big grin here]
What I tried first
Initially, I thought we could tell samba to use a name other than that
returned by hostname. Specifically, I thought that setting the following
in /usr/local/etc/smb.conf would suffice:
netbios name = fred
But I couldn't get that to work. So I took another approach.
Changing the hostname
It's time to change the hostname of my FreeBSD box.
All done. Now when I start nmbd, I get this in the logs:
$ tail log.nmb
1999/06/12 23:26:34 netbios nameserver version 1.9.18p8 started
Copyright Andrew Tridgell 1994-1997
standard input is not a socket, assuming -D option
And a quick check shows that both smbd and nmbd are running.