# Samba Server in Jail with broadcasting nmbd



## danny (Jul 7, 2012)

Hi, 

I use FreeBSD 9.0-RELEASE-p3 with samba36-3.6.5 on my NAS and wanna put my Samba sever in a jail. If I do that and start Samba, I can manually access the Samba shares from other hosts without any problems. There's one issue, though:

My WD TV Live streamer only finds/lists Samba shares broadcasting via nmbd, which doesn't work since I put it in the jail. So I'm looking for a way to allow nmbd broadcasting from inside the jail.

Error message:

```
nmbd/nmbd_subnetdb.c:127(make_subnet)
  nmbd_subnetdb:make_subnet()
    Failed to open nmb bcast socket on interface 192.168.1.255 for port 137.  Error was Can't assign requested address
```

The jail gets its IP address from an alias:
/etc/rc.conf part of host

```
ifconfig_bge0="inet 192.168.1.38 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
# Jail alias 
ifconfig_bge0_alias0="inet 192.168.1.39 netmask 255.255.255.0"
```

From outside the jail nmbd's broadcasting worked fine, so I think my smb.conf is alright.

I already read these topics:
http://forums.freebsd.org/showthread.php?t=20350
http://forums.freebsd.org/showthread.php?t=19918

But they obviously don't need nmbd to work inside the jail.

Any ideas on how to allow broadcasting or any workarounds (bridge, NAT, ...)?


Best Regards
Danny


----------



## kpa (Jul 7, 2012)

Try with netmask 255.255.255.255 on the alias0 address. That's what it's supposed be since it's in the same network with the main address of the interface.


----------



## danny (Jul 7, 2012)

O.k., I changed the settings to:

```
ifconfig_bge0_alias0="inet 192.168.1.39 netmask 255.255.255.255"
```

Thanks, the error message is gone and nmbd keeps running, but the WD TV (192.168.1.41) still doesn't recognize the Samba share. Maybe the smb.conf setting for "interfaces" needs to be adjusted. This is how it looks right now:

/usr/local/etc/smb.conf from jail:

```
[global]
        workgroup = MEDIA
        server string = NAS
        local master = No
        domain master = No
        hosts allow = 192.168.1.33 192.168.1.36 192.168.1.37 192.168.1.41
        read only = yes
        interfaces = bge0 192.168.1.39/255.255.255.255
        bind interfaces only = yes

[Multimedia]
(...)
```
`ifconfig` inside jail:

```
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether e8:39:35:ea:4a:86
        inet 192.168.1.39 netmask 0xffffffff broadcast 192.168.1.39
ifconfig: socket(AF_INET6, SOCK_DGRAM): Protocol not supported
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
ipfw0: flags=8800<SIMPLEX,MULTICAST> metric 0 mtu 65536
ifconfig: socket(AF_INET6, SOCK_DGRAM): Protocol not supported
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
ifconfig: socket(AF_INET6, SOCK_DGRAM): Protocol not supported
```


UPDATE:

When starting the Samba server on the host, netstat shows the broadcast entry and WD TV works:

```
udp4       0      0 192.168.1.255.138      *.*
```

But when starting it in the jail, `netstat` doesn't show this entry and so WD TV doesn't work.

With interfaces set to 192.168.1.39/32 nmbd doesn't show any errors, but it doesn't broadcast as well.


----------



## ScruffyDan (Jul 5, 2014)

Did you ever find a fix for this? I have the same issue (though I am on FreeBSD 10 RELEASE).


----------



## dpejesh (Jul 14, 2014)

If I remember correctly you have to use remote announce in smb.conf:


```
remote announce = 192.168.1.255/WORKGROUP
```
Otherwise nmbd will see the interface inside the jail has an address of 192.168.1.39/32 and attempt to use 192.168.1.39 as the broadcast address, so remote announce allows you to override it.


----------



## ScruffyDan (Jul 15, 2014)

Thanks. I'll have to keep a mental note of this when I rebuild the server. I gave up on getting this to work for now, jails are overkill for a simple home server but I wanted to implement them as a learning exercise.

Does something similar work for Netatalk/Avahi? When I do a rebuild I will want that in a jail also.


----------

