閒聊

Linux 安裝samba網路芳鄰(CIFS)

先安裝samba

yum install samba samba-client samba-common -y

然後vi /etc/samba/smb.conf

[global]
        workgroup = WORKGROUP
        security = user
        passdb backend = tdbsam
        min protocol = NT1
        client max protocol = SMB3
        printing = cups
        public = yes
map to guest = Bad Password
        guest ok = yes
        printcap name = cups
        load printers = yes
        cups options = raw
        browseable = yes
display charset = UTF8
dos charset = cp950
unix charset = UTF8

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

[printers]
        comment = All Printers
        path = /var/tmp
        printable = Yes
        create mask = 0600
        browseable = No

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        write list = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775
[share]
    path = /samba
    public = yes
    browseable = yes
    read only = no
    create mask = 0775
    directory mask = 0775
    security = share
    force user = root 

其中

display charset = UTF8
dos charset = cp950
unix charset = UTF8

是為了讓他支援中文的目錄名稱,samba裡面big5叫做cp950這樣,但是本機linux是utf8 所以要這樣設定

可以參閱 http://www.360doc.com/content/14/0106/16/7991404_343082733.shtml

還有 map to guest = Bad Password guest ok = yes

是為了免密碼登入網路芳鄰,所以要在global加入這個 可以參閱https://read01.com/zh-tw/4mmOB7.html#.YVLAbbgzbcs

service smb restart

sudo iptables -A INPUT -p tcp –dport 139 -j ACCEPT

sudo iptables -A INPUT -p tcp –dport 445 -j ACCEPT

sudo firewall-cmd –permanent –zone=FedoraServer –add-service=samba

sudo firewall-cmd –reload

上面這樣應該就可以了,你可以在自己電腦下smbclient -L //127.0.0.1 看看服務有沒有起來,如果windows連不到的話,可以再找另一台linux電腦下smbclient -L //那台IP 看看有沒有成功,通常可能會是上面的firewall擋住了,你可以把firewall關掉,或是把port開啟起來

Be the First to comment.

Leave a Comment

發佈留言必須填寫的電子郵件地址不會公開。