Samba@FreeBSD 架設程序
Chienwen, DICT.TW
2007.02.24
update:2007.03.29
安裝前準備:
- 你必須熟悉如何使用電腦,包括如何開機與關機。
- 你己經安裝好 FreeBSD,並且 ports tree 已更新完畢。
安裝 Samba:
- 由 ports 安裝 Samba:
# /usr/ports/net/samba3 ; make install |
- 出現選單,依照內定預設值,按 Tab 選擇 OK,再按 Enter。
Options for samba 3.0.24,1
[X] LDAP
With LDAP support
[X] ADS
With Active Directory support
[X] CUPS
With CUPS printing support
[X] WINBIND
With WinBIND support
[X] ACL_SUPPORT
With ACL support
[ ] FAM_SUPPORT
With File Alteration Monitor
[X] SYSLOG
With Syslog support
[ ] QUOTAS
With Disk quota support
[X] UTMP
With UTMP accounting support
[ ] MSDFS
With MSDFS support
[ ] PAM_SMBPASS
With PAM authentication vs passdb backends
[ ] CLUSTER
With experimental cluster support
[ ] EXP_MODULES
With experimental modules
[X] POPT
With system-wide POPT library
[ ] MAX_DEBUG
With maximum debuging
|
- 複製 Samba CONF 檔案:
# cp /usr/local/etc/smb.conf.default /usr/local/etc/smb.conf |
編輯 Samba CONF 檔案 -- 全域設定 (Global Settings):
- 參數: 'workgroup'
範例:
workgroup = WORKGROUP
- 參數: 'server string'
範例:
server string = %h Samba Server
'%h' 代表主機名稱變數。
- 參數: 'log file'
範例:
log file = /var/log/samba/%m.log
編輯 Samba CONF 檔案 -- 使用者權限 (Share Definitions):
- 設定使用者家目錄,原始設定為:
[homes]
comment = Homes Directories
browseable = no
writable = yes
更改為:
[homes]
comment = Home directory for %u on %h
browseable = no
writable = yes
path = /usr/home/%u/
valid users = %S
- 設定共享資料夾,所有使用者都可以讀寫檔案:
# A publicly accessible directory, read/write to all users.
[public]
comment = %h Shared Public Directory
path = /usr/home/samba/public
force directory mode = 0777
force create mode = 0777
force group = nobody
force user = nobody
public = yes
writeable = yes
read only = no
- 測試 Samba CONF 檔案有無語法錯誤:
# /usr/local/bin/testparm | more |
- 建立共享資料夾:
# cd /usr; mkdir home ; cd home ; mkdir samba ; cd samba ; mkdir public
# chmod 777 public |
使用者帳號設定:
- 使用者必須同時設定兩種帳號: OS database (FreeBSD 的使用者帳號)、Samba user database (Samba 的使用者帳號)
才能正常登入 Samba 伺服器。
- 建立 OS database (FreeBSD 的使用者帳號):
adduser 用法,請參閱 FreeBSD Man Pages、
FreeBSD 使用者管理。
- 建立 Samba user database (Samba 的使用者帳號):
(假設帳號名稱為 winuser)
顯示:
New SMB password:
鍵入 Windows 密碼,顯示:
Retype new SMB password:
再鍵入 Windows 寫碼確認。
啟動 Samba:
- 設定開機時,自動啟動 Samba,在 /etc/rc.conf 加入這一行設定:
- 若有更改 Samba CONF 檔案,則須重新啟動 Samba:
# /usr/local/etc/rc.d/samba.sh restart |
防火牆設定:
- Samba 使用下列的通訊埠: (註)
Port 135/TCP - used by smbd
Port 137/UDP - used by nmbd
Port 138/UDP - used by nmbd
Port 139/TCP - used by smbd
Port 445/TCP - used by smbd
- 以 Packet Filter 為例說明,必須在 /etc/pf.conf 加入這些設定:
# Macro
ext_if = "網路卡"
local_nets = "允許連線網域"
samba = "{ 135, 137, 138, 139, 445 }"
# Filter
pass in on $ext_if proto { tcp udp } from $local_nets to any port $samba flags S/SA keep state
|
登入 Windows:
- 你現在可以從「網路上的芳鄰」瀏覽 Samba server 了!
|