您的位置:首页 > Web前端

Fedora12 Samba 服务器的搭建

2013-07-12 07:54 323 查看
原文地址:http://blog.csdn.net/jsfzdd/article/details/6158094

1 安装samba


[root@localhost ~]# yum –y install samba ← 通过网络安装samba



2 添加samba用户(用户名称叫“samba”)

[root@localhost ~]# adduser samba ← 添加用户samba(系统自动在/home下创建samba文件夹)

[root@localhost ~]# smbpasswd -a samba ← 将系统用户samba加入到 samba 用户数据库

New SMB password: ← 输入该用户用于登录 samba 的密码

Retype new SMB password: ← 再次确认输入该密码



3 配置samba

[root@localhost ~]# cd /etc/samba/ ← 进入samba配置目录

[root@localhost ~]# cp smb.conf smbbak.conf ← 修改samba配置文件之前,首先对其进行备份(一个好习惯)

[root@localhost ~]# vi /etc/samba/smb.conf ← 打开配置文件



在配置文件的最后加入下列内容:

[samba]

comment = samba ← samba描述

path = /home/samba ← 共享目录

public = no ← 是否允许guest用户访问(相当于guest ok = yes/no)

writable = yes ← 是否可写

browseable = yes ← 是否允许浏览(该行可以不写)

valid users = @samba ← 访问用户(可以有多个,如:@samba @testuser ……)



4 开放防火墙端口

[root@localhost ~]# cd /etc/sysconfig/ ← 进入防火墙配置目录

[root@localhost ~]# cp iptables iptablesbak ← 修改端口配置文件之前,首先对其进行备份(一个好习惯)

[root@localhost ~]# vi /etc/sysconfig/iptables ← 打开配置文件

在配置文件中加入下列内容:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT



[root@sample ~]# /etc/rc.d/init.d/iptables restart ← 重新启动iptables,使新的规则生效

Flushing firewall rules:          [ OK ]

Setting chains to policy ACCEPT: filter [ OK ]

Unloading iptables modules:       [ OK ]

Applying iptables firewall rules:      [ OK ]



5 启动samba服务(含两个守护进程:smb nmb)

[root@sample ~]# chkconfig smb on ← 设置samba自启动

[root@sample ~]# chkconfig --list smb ← 确认samba启动标签,确认2-5为on的状态

smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@sample ~]# chkconfig nmb on ← 设置nmb自启动

[root@sample ~]# chkconfig --list nmb ← 确认nmb启动标签,确认2-5为on的状态(测试发现即使都为off也不影响samba服务)

nmb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@sample ~]# /etc/rc.d/init.d/smb start ← 启动samba服务

Starting SMB services:       [ OK ]

[root@sample ~]# /etc/rc.d/init.d/nmb start ← 启动nmb服务

Starting NMB services:       [ OK ]



6 Windows访问samba服务

在运行中输入 //192.168.0.8 (samba服务器IP)即可对samba共享目录进行访问。



【※】

问题1:在一切配置正常的情况下,经常出现客户端访问异常(无法成功登陆或可以看到共享文件夹却无法进入等情况):

原因一:Fedora防火墙没有允许samba端口访问。

原因二:Federa中的安全子系统SELinux的原因,可将其关闭。

[root@localhost ~]# setenforce 0 ← 关闭SELinux

问题2:windows登陆samba时,提示samba不允许一个用户使用一个以上用户名与一个服务器或共享资源的多重连接。

解决办法:windows运行中输入命令行“net use * /del /y”后,重新登陆samba。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: