Advice on configuring PCBSD as a network file server with NFS and Samba for BSD and Windows access (PCBSD 1.5.x and 7.0.x)
There are several Server Configuration files that must be modified to operate an NFS Server with Samba access. Most of this information is readily available on the web. The thing that is critical to making it work with PCBSD is to modify /etc/pf.conf to let NFS and Windows clients pass through the pf firewall. This is the list of files to modify:
1. /etc/exports (1 line)
2. /etc/pf.conf (3 lines)
3. /etc/rc.conf (3 lines)
4. /etc/hosts.allow (optional)
5. /usr/local/etc/smb.conf (many lines)
In these examples, the local network uses:
Tcp/ip addresses in the range 192.168.1.x and a netmask of 255.255.255.0.
The server is called "server" and uses a fixed ip address of 192.168.1.100
The files to share are stored in either the home directory or at a directory called /server_files
The client mount point is at /mnt/server
Part 1. ==================== Modify /etc/exports (SERVER) ===================
Exporting the "home" directory:
|
Code:
|
# identify the directory to export, the local network address, & net mask
/usr/home/IR -network 192.168.1.0 -mask 255.255.255.0 |
or exporting another directory:
|
Code:
|
/server_files -network 192.168.1.0 -mask 255.255.255.0 |
Part 2. ==================== Modify /etc/pf.conf (SERVER) ===================
# at the top of the file, define a macro variable to identify the local network
|
Code:
|
#
lan = "192.168.1.0/24"
# |
At the end of the file, add lines to pass all traffic to/from local network.
Notice the local network is identified here as the macro variable $lan.
Here, xl0 is the network interface card (NIC)
|
Code:
|
#
pass in on xl0 from $lan to any keep state
pass out on xl0 from any to $lan keep state
# |
Part 3. ==================== Modify /etc/rc.conf (SERVER) ===================
# add the next three lines to make the computer an nfs file server
# see further below to configure an nfs client
|
Code:
|
rpcbind_enable="yes"
nfs_server_enable="yes"
mountd_flags="-r" |
Part 4. ==================== Optional Modifications to /etc/hosts.allow (SERVER) ===============
No changes are necessary, but you could change anywhere the file references an ip address or netmask to match your particular network.
Part 5. =================== Modify /usr/local/etc/smb.conf (Server) ======================
|
Code:
|
[global]
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
workgroup = MYGROUP <------------------------------------ (change to your Windows workgroup)
# server string is the equivalent of the NT Description field
server string = Samba Server <---------------------------(change to meet your naming needs)
# Security mode. Defines in which mode Samba will operate. Possible
# values are share, user, server, domain and ads. Most people will want
# user level security. See the Samba-HOWTO-Collection for details.
security = user <------------------------------------ (change to security = share )
# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
; hosts allow = 192.168.1. 127. <-----------(change to match the 1st three parts of your network tcp address, keep 127. )
* * *
[homes]
comment = Home Directories
browseable = no
writable = yes
* * *
[printers]
comment = All Printers
path = /usr/spool/samba
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = no
printable = yes
#
# >>> Custom Additions to Locate Files and Permit Access <<<==============================
#
[FK_SERVER] <------------------- Section Label, here w/ my server's name
comment = general user documents and files
path = /server_files <------------------ Path to location of the files you want to share
public = yes
read only = no
writeable = yes
browseable = yes
guest ok = yes
available = yes
guest account = nobody
force group = nogroup
force user = nobody
create mask = 0777
directory mask = 0777
nt acl support = No
#
# End Samba Changes |
To access the NFS Server with a PCBSD CLIENT, you must modify one configuration file ( /etc/rc.conf ) and create a mount point on the client directory tree:
# Add this line to /etc/rc.conf
Make Mount Point on Client Directory Tree
Now everything should be ready to actually mount a remote file system. In these examples the server's name will be "server" and the client's name will be "client."
Mounting the NFS Server
Execute a command like this as root on the client (Syntax: # mount_nfs <server_IP>:<server_dir_path> /<mount_point>)
|
Code:
|
# mount_nfs 192.168.1.100:/home/IR /mnt/server <--- mounts the home directory
or
# mount_nfs 192.168.1.100:/server_files /mnt/server <----- mounts the server files |
If you want to mount both the home directory and the server files, you need to define two export lines and two different mount points.
On the Windows client, you step through "My Network Places" until you see the PCBSD share. It helps to go into "My Computer" or "Windows Explorer" to "Map a Network Drive" to a drive letter.