# samba in jail



## ccaptainhastings3 (Feb 25, 2010)

I have

```
samba# testparm
Load smb config files from /usr/local/etc/smb.conf
Processing section "[homes]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
         netbios name = RAID
         interfaces = vr0, 192.168.2.214

[homes]
         read only = No
```


```
more /usr/local/etc/smb.conf
[global]
netbios name=raid
workgroup=workgroup
encrypt passwords=yes
interfaces = vr0 192.168.2.214

[homes]
readonly=no
```

as just a basic setup I can access it fine with
\\192.168.2.214
but not \\raid. I have tried it with and with out the interfaces option


```
/usr/local/etc/rc.d/samba status
nmbd is running as pid 56868.
smbd is running as pid 56874.
winbindd is running as pid 56880
```



```
samba# tail -n 10 /var/log/samba/log.nmbd
[2010/02/21 13:05:47, 0] lib/interface.c:load_interfaces(229)
   WARNING: no network interfaces found
[2010/02/21 13:05:52, 0] lib/interface.c:load_interfaces(229)
   WARNING: no network interfaces found
```
and log.smbd just shows cups error


```
samba-3.0.37,1
FreeBSD 8.0-RELEASE
```

I could just setup some internal dns of course instead of depending on samba server to broadcast but it is yet another service to configure. Samba works fine out of jail but it would be handy to be able to do 

Thank you


----------



## JimW (Feb 26, 2010)

ccaptainhastings3 said:
			
		

> I could just setup some internal dns of course instead of depending on samba server to broadcast but it is yet another service to configure. Samba works fine out of jail but it would be handy to be able to do



You can set up your Samba server to do name resolution with your Windows workstations by also making it a WINS Server.

Add this to your *smb.conf* file in the Global Section....


```
[global]
	wins support = yes
	name resolve order = wins hosts bcast
```

Some more info regarding this can be found here....

http://oreilly.com/catalog/samba/chapter/book/ch07_03.html

http://www.samba.org/samba/docs/man/Samba-Developers-Guide/wins.html

If you only have a couple of workstations, you could also just edit the *hosts* file on the Windows workstations themselves to include the IP address of your Samba server.

Good Luck.


----------



## ccaptainhastings3 (Feb 26, 2010)

JimW said:
			
		

> You can set up your Samba server to do name resolution with your Windows workstations by also making it a WINS Server.
> 
> Add this to your *smb.conf* file in the Global Section....
> 
> ...



Thanks Jim but no luck I think I may try a vnet jail as its seems to be the networking side of things giving the problem

```
Netbios nameserver version 3.0.37 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2009
[2010/02/26 07:25:01, 0] nmbd/asyncdns.c:start_async_dns(151)
  started asyncdns process 50906
[2010/02/26 07:25:01, 0] lib/interface.c:load_interfaces(229)
  WARNING: no network interfaces found
[2010/02/26 07:25:01, 0] nmbd/nmbd_subnetdb.c:create_subnets(190)
  create_subnets: No non-loopback local interfaces !
```


----------



## mamalos (Feb 26, 2010)

I once tried to install samba as a pdc of my domain in a jail, but I didn't manage to make it work properly. This had to do with broadcast requests that cifs uses in order to interoperate with clients and servers.

My jail belonged to another subnet than that of its host. So, that was my problem. It was as if I wanted to serve samba behind nat, which is an issue.

If I had used a bridge-jail instead, I suppose the setup would have worked.

Try using bridged jails, it may come in handy (I don't know your setup).


----------



## ccaptainhastings3 (Feb 27, 2010)

mamalos said:
			
		

> I once tried to install samba as a pdc of my domain in a jail, but I didn't manage to make it work properly. This had to do with broadcast requests that cifs uses in order to interoperate with clients and servers.
> 
> My jail belonged to another subnet than that of its host. So, that was my problem. It was as if I wanted to serve samba behind nat, which is an issue.
> 
> ...




Yep samba works a treat in a bridged jail. Windows machines can access it by name straight away with no further configuration need.

```
nmblookup test
querying test on 192.168.2.255
192.168.2.216 test<00>
```

I can setup a bridged jail fine using this method and running by hand all though after a few minutes it drops the connection for a second or two then comes back on line


```
mars# mount -t devfs devfs /usr/jails/robo.example.com/dev
mars# jail -c vnet host.hostname=robo.example.com path=/usr/jails/robo.example.com persist
mars# ifconfig bridge create
bridge0
mars# ifconfig epair create
epair0a
mars# ifconfig bridge0 addm vr0 addm epair0a
mars#
mars# ifconfig bridge0 10.1.0.1
mars# ifconfig epair0a 10.0.0.1
mars# ifconfig epair0b vnet 6
mars# jexec 6 ifconfig epair0b 192.168.2.216
mars# jexec 6 /etc/rc.d/sshd status
sshd is not running.
mars# jexec 6 /etc/rc.d/sshd start
Starting sshd.
```


```
robo# ifconfig
lo0: flags=8008<LOOPBACK,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 02:c0:64:00:06:0b
        inet 192.168.2.216 netmask 0xffffff00 broadcast 192.168.2.255
        inet6 fe80::c0:64ff:fe00:60b%epair0b prefixlen 64 scopeid 0x2
robo# ping google.com
PING google.com (209.85.229.105): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
^C
--- google.com ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
robo# route add default 192.168.2.1
add net default: gateway 192.168.2.1
robo# ping google.com
PING google.com (209.85.229.99): 56 data bytes
64 bytes from 209.85.229.99: icmp_seq=0 ttl=54 time=43.653 ms
64 bytes from 209.85.229.99: icmp_seq=1 ttl=54 time=41.693 ms
^C
```


I have tried moving it into rc.conf as it should be but cant for the life of me get it to work that way.
With out this http://lifanov.com/doc/vimage.html I would not have even got this far


----------



## mamalos (Feb 28, 2010)

ccaptainhastings3 said:
			
		

> I have tried moving it into rc.conf as it should be but cant for the life of me get it to work that way.
> With out this http://lifanov.com/doc/vimage.html I would not have even got this far



This is a very nice article indeed! I had read about separate network stacks that would be used in fbsd8 jails, but I had never read an example until now. I'll try to see if I could get my jails working that way, and if I will manage to make them start via rc.conf.

If you have any news on this, please share it.

Nice job.


----------

