Print View

Setting up Samba
Updated: 10/21/2003


General Information

Just how do you get your Windows machines to access your FreeBSD server and printers?  The trick is with Samba.  Here I'm going to show you how to setup Samba so your server will appear in 'My Network Places' and configured for user account access.

Requirements

  1. Local root access on the box or be able to su to root.
  2. A SSH client that supports ANSI colors such as puTTy or SecureCRT (if you are setting it up remotely).
  3. Your favorite text editor (we will use nano).
  4. Your favorite web browser (we will use lynx).

Installation

#
#
cd /usr/ports/net/samba
make install clean
You will be prompted with a configuration menu to choose additional options to be installed.  For this guide we won't choose any.

Configuration

Now that Samba is installed, we need to configure it for your network before we fire it up.

Section A -- inetd

# nano /etc/inetd.conf
Look for and uncomment the following:
swat    stream  tcp     nowait/400      root    /usr/local/sbin/swat    swat
Save the changes and restart inetd
# killall -HUP inetd

Section B -- Samba

Bring up SWAT (Samba Web Administration Tool)
# lynx http://localhost:901
  1. log in with root
  2. Navigate to 'Globals'
  3. Change netbios name to whatever you want your server to come up as in 'My Network Places'
  4. Choose 'yes' to encrypt passwords
  5. Select 'Commit Changes' to save
  6. Navigate to 'Shares'
  7. Next to 'Create Share' type in your share name (I used 'Share') and then select 'Create Share'
  8. Type in the complete path for the directory you want to share
  9. Choose 'no' for read only if you want your users to be able to write
  10. Choose 'yes' for guest ok to allow for anonymous access to the shared directory
  11. Select 'Commit Changes' to save
  12. Navigate to 'Password Management'
  13. Type in a valid user account that already exists in /etc/passwd
  14. Type in the password twice and select 'Add User'
  15. Navigate to 'Status'
  16. Start both smbd and nmbd

Note:  Any time you make a future change to the configuration, you need to restart both services.

You now can test this by logging in through 'My Network Places.'

Author: Jon LaBass
jon at bsdguides dot org

Find this guide useful?
Support the author:


14 Comments

Posted by on July 16, 2004 at 9:17:29 am EEST

Excellent guide it taught one of our new admins whats going on with Samba :)


Posted by X-Istence on July 16, 2004 at 9:17:29 am EEST

Great guide. Just one thing, you need to killall -HUP inetd before the changes you just made to its config apply, otherwise you wont be able to access SWAT.


Posted by on July 16, 2004 at 9:17:29 am EEST

Awesome! Your instructions worked like a charm.


Posted by Hovi on July 16, 2004 at 9:17:29 am EEST

Thank you very much!!Never knew it was this EZ!!


Posted by mfaridi on July 31, 2006 at 12:05:36 pm EEST

I install samaba 3 in FreeBSD 6.1

I have two hard disk one hard disk for FreeBSD and another hard disk for Windows
I want share windows folder in FreeBSD

everthing you said I do
but when I type
smb://192.168.0.90

first time I see messages it said can not find server after I try again
samba run
but I can not see any folder
I can not see folder I share before with samba

partitions windows all of them is NTFS


Posted by Jon on July 31, 2006 at 4:09:59 pm EEST

Sounds like the share might not be browsable.  Have you tried accessing the share by the full path?  (ex. smb://192.168.0.90/share)


Posted by mfaridi on July 31, 2006 at 5:04:33 pm EEST

yes but it does not work


Posted by Jon on July 31, 2006 at 7:00:30 pm EEST

Do you have a firewall running on your FreeBSD server?  If you do, turn it off to see if it you can access the share.  If that works, you will need to make some rules to allow TCP ports 137, 139, and 445.  If that does not work, please email me a copy of your smb.conf file and I will try to find the problem.


Posted by mfaridi on July 31, 2006 at 7:17:02 pm EEST

I do not runnig firewall this is smb.conf

# Samba config file created using SWAT
# from 127.0.0.1 (127.0.0.1)
# Date: 2006/07/31 17:30:30

[global]
netbios name = HARDWARE
server string = Samba Server
guest account =
log file = /var/log/samba/log.%m
max log size = 50
dns proxy = No

[homes]
comment = Home Directories
read only = No
browseable = No

[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No

[myprogram]
comment = program
path = /mnt/win-g/My Programs/
acl group control = Yes
directory mask = 0777
guest ok = Yes
store dos attributes = Yes
dmapi support = Yes
set directory = Yes
dos filemode = Yes
dos filetime resolution = Yes

[xfardic]
path = /home/test2
guest ok = Yes
available = No


Posted by Jon on July 31, 2006 at 8:33:20 pm EEST

I assume you are trying to access your [myprogram] share.  First, I would try simplifying [myprogram] down to this:

[myprogram]
comment = program
path = /mnt/win-g/My Programs/
guest ok = Yes

Then from your Windows machine, try accessing the share at \\ip-address\myprogram and see if you can access it.  If it still fails, check your log files at /var/log/samba and see what they say.

Also, on another note, are both computers in the same workgroup?  And can you read the nfts drive locally from your FreeBSD server?


Posted by mfaridi on August 01, 2006 at 8:18:06 am EEST

Dear Sir
My comouter have two hard disk first hard disk is for windows and second hard disk use for FreeBSD
I want share windows folder in my computer


Posted by Jon on August 01, 2006 at 7:07:13 pm EEST

So you are trying to access your NTFS drive that is in your FreeBSD computer from that same FreeBSD computer?  If so, Samba is not the right tool to use for this because you can mount it locally using mount_ntfs.

If you are trying to share that NTFS drive so other Windows computers can access it, these procedures will work.  If what you are trying to accomplish is neither of these scenarios, please explain to me in great detail the setup of all the computers involved and what exactly you need accomplished so I can better assist you.


Posted by darkaxi0m on June 25, 2007 at 9:47:00 am EEST

how would you set both smbd and nmbd to start at boot?


Posted by Jon on July 02, 2007 at 5:23:46 am EEST

To start both daemons at boot, add the following to /etc/rc.conf:

samba_enable="YES"


Copyright 2003 - 2009 BSD Guides.  All rights reserved.

About | Terms of Use | Privacy | Contact