# samba problem probably related to dnsmasq. [SOLVED]

## dj_farid

I have had my samba server running without me changing the configuration on it for some time now.

I use a Windows XP machine to connect to the share on the server. It worked nicely when I had my XP machine with static IP.

Then I configured the SP machine to use DHCP instead...

The XP machine can see the shared folder as usual. It can access it but it takes a long time (approx 1 minute).

So the problem is that it takes very long to access the share on the server.

This is what /var/log/messages says:

```
Jan  9 11:32:20 gen2 nmbd[4459]: [2006/01/09 11:32:20, 0] nmbd/nmbd_incomingdgrams.c:process_local_master_announce(311)

Jan  9 11:32:20 gen2 nmbd[4459]:   process_local_master_announce: Server WINXP at IP 192.168.0.115 is announcing itself as a local master browser for workgroup WORKGROUP and we think we are master. Forcing election.

Jan  9 11:32:20 gen2 nmbd[4459]: [2006/01/09 11:32:20, 0] nmbd/nmbd_become_lmb.c:unbecome_local_master_success(149)

Jan  9 11:32:20 gen2 nmbd[4459]:   *****

Jan  9 11:32:20 gen2 nmbd[4459]:

Jan  9 11:32:20 gen2 nmbd[4459]:   Samba name server GEN2 has stopped being a local master browser for workgroup WORKGROUP on subnet 192.168.0.1

Jan  9 11:32:20 gen2 nmbd[4459]:

Jan  9 11:32:20 gen2 nmbd[4459]:   *****

Jan  9 11:32:37 gen2 nmbd[4459]: [2006/01/09 11:32:37, 0] nmbd/nmbd_become_lmb.c:become_local_master_stage2(396)

Jan  9 11:32:37 gen2 nmbd[4459]:   *****

Jan  9 11:32:37 gen2 nmbd[4459]:

Jan  9 11:32:37 gen2 nmbd[4459]:   Samba name server GEN2 is now a local master browser for workgroup WORKGROUP on subnet 192.168.0.1

Jan  9 11:32:37 gen2 nmbd[4459]:

Jan  9 11:32:37 gen2 nmbd[4459]:   *****

```

And it keeps on doing this over and over.

/etc/dnsmasq.conf:

```

# Never forward plain names (with a dot or domain part)

domain-needed

# Never forward addresses in the non-routed address spaces.

bogus-priv

# Uncomment this to enable the integrated DHCP server, you need

# to supply the range of addresses available for lease and optionally

# a lease time. If you have more than one network, you will need to

# repeat this for each network on which you want to supply DHCP

# service.

dhcp-range=192.168.0.50,192.168.0.150,72h

# Set the NTP time server address to be the same machine as

# is running dnsmasq

dhcp-option=42,0.0.0.0

# The following DHCP options set up dnsmasq in the same way as is specified

# for the ISC dhcpcd in

# http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt

# adapted for a typical dnsmasq installation where the host running

# dnsmasq is also the host running samba.

# you may want to uncomment them if you use Windows clients and Samba.

dhcp-option=19,0           # option ip-forwarding off

dhcp-option=44,0.0.0.0     # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)

dhcp-option=45,0.0.0.0     # netbios datagram distribution server

dhcp-option=46,8           # netbios node type

dhcp-option=47             # empty netbios scope.

# Set the DHCP server to authoritative mode. In this mode it will barge in

# and take over the lease for any client which broadcasts on the network,

# whether it has a record of the lease or not. This avoids long timeouts

# when a machine wakes up on a new network. DO NOT enable this if there's

# the slighest chance that you might end up accidentally configuring a DHCP

# server for your campus/company accidentally. The ISC server uses the same

# the same option, and this URL provides more information:

# http://www.isc.org/index.pl?/sw/dhcp/authoritative.php

dhcp-authoritative

```

smb.conf:

```

testparm

Load smb config files from /etc/samba/smb.conf

Processing section "[pub]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters

[global]

        server string = Gentoo %v

        interfaces = lo, eth1

        bind interfaces only = Yes

        security = SHARE

        guest account = smbguest

        lanman auth = No

        max log size = 50

        min protocol = NT1

        change notify timeout = 300

        deadtime = 15

        socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 IPTOS_LOWDELAY

        os level = 65

        lm announce = No

        domain master = Yes

        wins support = Yes

        invalid users = root, @wheel

        hosts allow = 192.168.0.100, 192.168.0., 127.0.0.1

        hosts deny = ALL

[pub]

        path = /glftpd/site

        guest only = Yes

        guest ok = Yes

```

My Windows XP machine:

```
C:\ipconfig /all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : winxp

        Primary Dns Suffix  . . . . . . . :

        Node Type . . . . . . . . . . . . : Hybrid

        IP Routing Enabled. . . . . . . . : No

        WINS Proxy Enabled. . . . . . . . : No

        DNS Suffix Search List. . . . . . : xxx.dyndns.org

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . : xxx.dyndns.org

        Description . . . . . . . . . . . : NVIDIA nForce Networking Controller

        Physical Address. . . . . . . . . : 00-15-F2-17-A5-52

        Dhcp Enabled. . . . . . . . . . . : Yes

        Autoconfiguration Enabled . . . . : Yes

        IP Address. . . . . . . . . . . . : 192.168.0.115

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.0.1

        DHCP Server . . . . . . . . . . . : 192.168.0.1

        DNS Servers . . . . . . . . . . . : 192.168.0.1

        Primary WINS Server . . . . . . . : 192.168.0.1

        Lease Obtained. . . . . . . . . . : den 9 januari 2006 08:04:48

        Lease Expires . . . . . . . . . . : den 12 januari 2006 08:04:48

```

What could cause the problem?Last edited by dj_farid on Fri Jan 13, 2006 3:00 pm; edited 1 time in total

----------

## mbar

try:

```
preferred master = yes
```

in [global] section.

Also, you could dump timeout/deadtime options from your config, just rely on defaults.

----------

## dj_farid

Thanks.

Removing the timeout and deadtime row made it a little faster. But I still get this in the log:

```
Jan  9 14:32:14 gen2 nmbd[31488]: [2006/01/09 14:32:14, 0] nmbd/nmbd_incomingdgrams.c:process_local_master_announce(311)

Jan  9 14:32:14 gen2 nmbd[31488]:   process_local_master_announce: Server WINXP at IP 192.168.0.115 is announcing itself as a local master browser for workgroup WORKGROUP and we think we are master. Forcing election.

Jan  9 14:32:14 gen2 nmbd[31488]: [2006/01/09 14:32:14, 0] nmbd/nmbd_become_lmb.c:unbecome_local_master_success(149)

Jan  9 14:32:14 gen2 nmbd[31488]:   *****

Jan  9 14:32:14 gen2 nmbd[31488]:

Jan  9 14:32:14 gen2 nmbd[31488]:   Samba name server GEN2 has stopped being a local master browser for workgroup WORKGROUP on subnet 192.168.0.1

Jan  9 14:32:14 gen2 nmbd[31488]:

Jan  9 14:32:14 gen2 nmbd[31488]:   *****

Jan  9 14:32:32 gen2 nmbd[31488]: [2006/01/09 14:32:32, 0] nmbd/nmbd_become_lmb.c:become_local_master_stage2(396)

Jan  9 14:32:32 gen2 nmbd[31488]:   *****

Jan  9 14:32:32 gen2 nmbd[31488]:

Jan  9 14:32:32 gen2 nmbd[31488]:   Samba name server GEN2 is now a local master browser for workgroup WORKGROUP on subnet 192.168.0.1

Jan  9 14:32:32 gen2 nmbd[31488]:

Jan  9 14:32:32 gen2 nmbd[31488]:   *****

```

Why does my XP workstation announcing itself to be a local master browser? All it's settings are done with dhcp.

----------

## mbar

Because Windows XP has "Computer Browser" (or sth like that, I've Polish version) enabled by default in Services. Go to Computer Management / Services and disable it. Do not touch Server and Workstation services tough.

----------

## dj_farid

Thank you!

The errors are gone now.

The strange thing is that it still is slower than before (when I had static IP) when I browse two directories deep. But atleast it is not unbearable.

----------

## mbar

So, one more thing for you to do:

Go into My Network Places / Properties, then display Properties of your Ethernet card (local connection). Click on TCP/IP Protocol, then hit Properties again. Click on Advanced. Display WINS tab, then change (in NetBIOS group) Default (use settings from DHCP) to "Enable NetBIOS through TCP/IP".

Mind you, the names are translated from Polish, but should sound somewhat familiar.

----------

## dj_farid

Still goes slowly. Maybe it's something else that is not ok with my setup.

I figured that I will mount the samba share on the same workstation but in linux...

```

# mount /mnt/gen2

timeout connecting to 192.168.0.1:445

# mount -t smbfs //gen2/pub /mnt/gen2

timeout connecting to 192.168.0.1:445

Password:

# ls /mnt/gen2

README.TXT 
```

fstab:

```

//gen2/pub             /mnt/gen2       smbfs           username=guest,password=guest  0 0

```

It will not mount if I have that line in fstab. It just gives a time out.

If I mount from the command line, it times out and asks for a password. I give the password "guest" and it works...

PS. mbar, all your translations have been correct so far  :Wink: 

----------

## mbar

Ahh.

So what is your kernel configuration? I think you should enable CIFS support and completly disable SAMBA in kernel. Then, use "cifs" instead of "smbfs" in fstab.

----------

## dj_farid

This is the kernel for the client, not the server you are talking about, right?

Do you have an explanation why it does like this?

----------

## mbar

For the server and client. Windows XP uses newer SMB protocol, CIFS. So it's useless to have SMB support in kernel, use CIFS instead, as it is newer and better performing.

You don't have to change anything related to "samba" (smbd) daemon packet (but it might be good to reemerge samba), just the kernel. Works for me, I have gentoo router/local file server, and two gentoo clients + two winxp clients on my LAN.

And one more thing, often overlooked when configuring samba: you have to add "/bin/false" line to the "/etc/shells" config file, if you want to allow guest user access to samba share.

----------

## dj_farid

I compiled my kernel with cifs now. I removed smb from the kernel since it's not needed.

Reading the help in make menuconfig says that cifs support in the kernel is not needed in the samba server, only the client.

So I did not re-compile the kernel in my server. It does not have samba nor cifs in the kernel.

I removed 

```
invalid users = root, @wheel
```

 from smb.conf. Still can't mount it. Neither from fstab or from commandline.

When mounting from the commandline, it stops after "password:", from fstab it just stops without displaying anything.

My guess is that I just have overlooked something simple. I have to read more man pages for samba I guess.

The good thing is that the time outs disappeared after recompiling the kernel with cifs...

----------

## mbar

I can only post my smb.conf as a reference:

```
[global]

workgroup = SIATKA

server string = Gateway %v

log file = /var/log/samba/log.%m

max log size = 256

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

getwd cache = yes

#aio read size = 65536

#aio write size = 65536

preferred master = yes

interfaces = lo eth0 eth1 ra0

bind interfaces only = yes

hosts allow = 127.0.0.1 10.0.0.0/24 10.0.1.0/24 10.0.2.0/24

hosts deny = 0.0.0.0/0

security = share

guest account = nobody

guest ok = yes

printcap name = cups

printing = cups

[printers]

comment = All printers

path = /var/spool/samba

browseable = no

guest ok = no

writable = no

printable = yes

public = yes

printer name = SamsungML-1520

[public]

browseable = yes

writable = yes

public = yes

create mode = 0766

guest ok = yes

path = /home/samba/public

[raid]

browseable = no

writable = yes

public = no

create mode = 766

guest ok = yes

path = /home/raid

[mp3]

browseable = yes

writable = no

public = yes

#create mode = 0766

guest ok = yes

path = /home/raid/mp3

[video]

browseable = yes

writable = no

public = yes

#create mode = 0766

guest ok = yes

path = /home/raid/video 

```

----------

## dj_farid

I fixed it!

It all had to do with iptables. I had port 445 blocked in the server  :Embarassed: 

Should have checked this earlier...

Anyway, thank you mbar!

----------

