1 / 22

Samba 服務架設 ( File and Print Server)

Samba 服務架設 ( File and Print Server). Kenduest ( 小州). mailto:kenduest@cynix.com.tw. What’s Samba. What’s Samba 由 SMB 談起, SMB 為 Server Message Block 簡寫, 是一種可以與不同電腦之間分享檔案、印表機等等 溝通的一種協定。 目前 Windows 與 OS/2 等系統都使用該協定。 在 Unix 系統下安裝使用 Samba 即可提供該服務。

Télécharger la présentation

Samba 服務架設 ( File and Print Server)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Samba 服務架設(File and Print Server) Kenduest (小州) mailto:kenduest@cynix.com.tw

  2. What’s Samba • What’s Samba • 由 SMB 談起,SMB 為 Server Message Block 簡寫, 是一種可以與不同電腦之間分享檔案、印表機等等 溝通的一種協定。 • 目前 Windows 與 OS/2 等系統都使用該協定。 • 在 Unix 系統下安裝使用 Samba 即可提供該服務。 • Microsoft 以 Microsoft Network 提供該服務。 • 在 Unix 系統上安裝 Samba 服務後,偽裝成為 Microsoft Network 上一個 Server 提供相關服務。

  3. Samba 由來 • Samba 由來 • Samba 想法,是澳洲坎培拉的 Andrew Tridgell 在 1991 年提出來的。 • 原本打算以 SMB 名義發行,不過因為 IBM 已經 註冊使用了 IBM PC Network SMB Protocol, 所以改以 Samba 命名之。 • Client 可以使用 TCP/IP (實際上是 TCP/IP 上的 NetBIOS 協定),或者是 NetBEUI、IPS/SPX 等方式連結,事後就可以透過 SMB 命令來存取 檔案、印表等服務。

  4. Samba 服務程式 • Samba 服務程式 • Samba 主要的兩個 Daemon 程式 • smbd • 管理 samba server 與 client 之間的連線資源 • 提供實際檔案存取、印表等等服務 • 身份確認、資源分享與鎖定 • nmbd • 用來提供模擬 NetBIOS 服務 • 提供 Wins 服務

  5. Samba 提供的程式 • Samba 提供的程式說明 • smbclient • 連線到提供分享資料主機進行瀏覽,提供 ftp 操作 • smbtar • 類似於 tar 指令存取操作 • smbstatus • 檢視目前連線分享狀態 • smbmount • 類似於 mount,把分享資源掛入系統目錄 • smbumount • 類似於 umount,卸下掛入的分享目錄

  6. Samba 提供的程式 • Samba 提供的程式說明 (續) • smbpasswd • 建立存取 Samba 主機的使用者密碼 (編碼) • testparm • 檢查並顯示 smb.conf 設定檔案內容

  7. 安裝 Samba 程式 • Download & Compile & Install • ftp://ftp.samba.org/pub/samba/ • http://coda.nctu.edu.tw/network/Samba/samba-latest.tar.gz # tar zxvf samba-latest.tar.gz # cd samba-2.0.7/source # ./configure --prefix=/usr/local/samba 有許多參數可以使用,請使用 ./configure –help 檢視 # make # make install • 另外可以安裝 swat 程式,可以透過 web 設定 samba • samba 在解開目錄內的 swat 目錄內。

  8. 安裝 Samba 程式 • 使用 RPM 直接安裝 • mount /mnt/cdrom • cd /mnt/cdrom/RedHat/RPMS • rpm –ihv samba* • samba 支援許多功能,預設編譯好的套件不一定 符合需求,有需要的話,可以抓取 .src.rpm 檔案, 安裝後到 /usr/src/redhat/SPECS 內找到 samba.spec 檔案內容,修改 configure 後面的參數,然後使用 rpm –ba samba.spec 打包出來的 rpm 檔案即可符合 自己的需求。

  9. 目錄檔案 • 若是使用 tarball 編譯安裝的部分: • /usr/local/samba : 主目錄 • /usr/local/samba/bin : 執行檔目錄 • /usr/local/samba/lib : 程式庫,包含其他重要檔案 • /usr/local/samba/man : manual 文件 • /usr/local/samba/etc: 設定檔案目錄 • /usr/local/samba/var : log 紀錄目錄 • /usr/local/samba/swat : swat 相關程式檔案 • 若是使用 RPM 安裝部分: • 與一般系統配置方式一樣。 • /etc 存放設定檔案,/var/log 存放 log 紀錄, /usr/sbin 存放執行檔案

  10. 啟動 Samba • 使用 standalone 啟動 • 建議讓 samba 使用 standalone 執行啟動 • RPM 安裝: • 使用 /etc/rc.d/init.d/smb start • 另外可以使用 ntsysv 選取 smb 讓開機後自動啟動 • Tarball 安裝,執行: • /usr/local/samba/smbd –D • /usr/local/samba/nmbd –D • 在 /etc/rc.d/rc.local 檔案內加入上面敘述自動 開機執行

  11. 啟動 Samba • 使用 inetd 啟動 • /etc/services 檔案加入: • netbios-ssn 139/tcp • netbios-ns 137/udp • /etc/inetd.conf 檔案內加入: • netbios-ssn stream tcp nowait root /usr/sbin/tcpd /usr/local/samba/bin/smbd • netbios-ns dgram udp wait root /usr/sbin/tcpd /usr/local/samba/bin/nmbd • 使用 killall –HUP inetd 或者是 /etc/rc.d/init.d/inet reload 重新啟動 inetd 服務。

  12. 測試 Samba 是否啟動 • 使用 smbclient 測試: • smbclient –U username –L 主機名稱 Linux:$ smbclient -L localhost added interface ip=192.168.2.169 bcast=192.168.2.191 nmask=255.255.255.192 Password: Anonymous login successful Domain=[MDKGROUP] OS=[Unix] Server=[Samba 2.0.7] Sharename Type Comment --------- ---- ------- IPC$ IPC IPC Service (Samba Server 2.0.7) Server Comment --------- ------- Workgroup Master --------- -------

  13. Samba 設定檔 • netbios name : 指定 netbios name 名稱 • 預設就是該主機的主 hostname • netbios name : hello • workgroup : 指定群組名稱 • workgroup : GroupName • server string : samba 說明 • server string = “This Samba Server” • hosts allow : 設定可以存取的主機 • hosts allow = 150.203.15.0/255.255.255.0 • printcap name : 指定參考 printcap 印表設定檔案位置 • printcap name = /etc/printcap • 配合 load printers = yes | no 決定是否啟動 printer 功能

  14. Samba 設定檔 • printing : 指定列印型別 • 一般是使用 bsd。mdk 等有提供 cups 列印機制, 則使用cups • printing = bsd • log file : 指定 log 檔案記錄位置 • log file = /var/log/samba/log.%m • %m : the NetBIOS name of the client machine • security : 指定分享安全等級 • security = share | user | server | domain • 詳見 security_level 檔案說明 • 需要使用者與密碼登入,選 user。一般分享,選 share

  15. Samba 設定檔 • encrypt passwords : 設定是否要使用編碼後的密碼傳輸 • encrypt passwords = yes | no • smb passwd file = /etc/smbpasswd • 若是設定使用編碼,才需要指定 password 檔案 • windows 95、98、nt (數個 sp 版本) 內有的使用 編碼密碼認證,有的則是使用編碼認證。 • 若是前面 security 選 user 的話,編碼密碼選項要 設定成為 yes 。 • windows 9x 版本都是使用編碼傳輸密碼。若是希望 可以讓 Windows 9x 使用明碼傳輸,把 samba 提供的登錄檔案匯入,然後 samba 端設定使用 不編碼傳輸即可使用。

  16. Samba 設定檔 • socket options : 設定 socket 傳輸參數: • 可以參考 samba 提供的 speed 文件說明 • 可以設定為: • socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 • interfaces : 告訴 samba 系統有哪些多個網路介面 • interfaces = eth0 192.168.2.10/24 192.168.3.10/255.255.255.0 • remote announce : 告訴 samba 向哪些網路廣播 • remote announce = 192.168.1.255/WorkGroup • samba 預設不會到處廣播,可以使用該參數 讓 samba 對某些網域主機進行廣播

  17. Samba 設定檔 • local master = yes | no • domain master = yes | no • domain logons = yes | no • os level = number • windows 95 = 1 • windows nt = 33 • windows nt client = 17 • name resolve order : 設定尋找 netbios name 順序 • name resolve order = lmhosts wins • wins support : 設定是否要成為 wins server • wins support = yes | no • 若是為 yes,local master 設定要為 yes

  18. Samba 設定檔 • wins server : 告訴 samba 使用某台主機為 wins • wins server = wins_server_ip • client code page : 告訴 samba 使用哪個 codepage 存取 • client code page = 950

  19. Samba 設定檔 • 分享項目,以 [share_name] 開始。 • 系統整體設定,是放在 [global] 項目區段內。 • 分享範例: [data] path = /home/data comment = Data Path writable = yes public = no read list = peter write list = allen

  20. Samba 設定檔 • [share_name] 區段內參數設定: • path : 指定分享的路徑 • comment : 註解說明 • writeable : 指定是否可以寫入 (同 writable、write ok) • read only : 指定是否唯讀 (是 writeable 的相反) • browsable : 指定是否可以瀏覽 (存在,預設看不到) • 與 browseable 相同 • create mode : 指定建立的檔案權限 • 建議為 0660 • directory mask : 指定建立目錄的權限 • 建議為 0770

  21. Samba 設定檔 • [share_name] 區段內參數設定: • public : 指定是否提供公開存取 (同 guest ok) • write list : 指定可以寫入的清單 • write list = @group_name1 , @group_name2 • write list = userid1 , userid2 • read list : 指定可以進入存取的清單 • read list = @group_name1, @group_name2 • read list = userid1,userid2 • printable : 配合分享 printer 區段。 • 使用 printcap name = /etc/printcap 、 load printers = yes 並配合 [printers] 區段設定

  22. 相關參考 • samba 主網站 • http://www.samba.org • samba 書籍 • Using Samba : (有免費 PDF 電子書可以 DownLoad) http://www.oreilly.com/catalog/samba/ • SAMBA徹底研究 http://www.drmaster.com.tw/0information.asp? 書號=NE20130 • samba 連結 • http://at.samba.org/samba/docs/ • http://teacher.fyjh.tpc.edu.tw/~windex/sambainstall/ sambainstall.html

More Related