Fedora9 Samba 服务器的搭建

 

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。

  

Fedora9 Samba server set up

Install samba
[root@localhost ~]# yum -y install samba ←through the network install samba

● Add samba user (user name called "samba")
[root@localhost ~]# adduser samba ← add users samba (the system automatically to create samba folder in the /home)
[root@localhost ~]# smbpasswd -a samba ← add the system user samba into samba user database
New SMB password: ← Enter the user password used to log on samba
Retype new SMB password: ← Enter the password again to confirm

● Configure samba
[root@localhost ~]# cd /etc/samba/ ← enter samba configuration directory
[root@localhost ~]# cp smb.conf smbbak.conf ← modify the samba configuration file, first back it up (good habit)
[root@localhost ~]# vi /etc/samba/smb.conf ← open the configuration file

Finally, in the configuration file add the following contents:
        [Samba]
        comment = samba ← samba description
        path = /home/samba ← shared directory
        public = no ← whether to allow guest user to access (equivalent to guest ok = yes / no)
        writable = yes ← whether to allow writing
        browseable = yes ← whether to allow browsing (the bank can not write)
        valid users = @samba ← the allowed user to access (you can have more than one

        such as: @samba @testuser ...)

● Open firewall ports
[root@localhost ~]# cd /etc/sysconfig/ ← enter the firewall configuration directory
[root@localhost ~]# cp iptables iptablesbak ← modify the port configuration file, first back it up (good habit)
[root@localhost ~]# vi /etc/sysconfig/iptables ← open the configuration file

In the configuration file to add the following:
-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@localhost ~]# /etc/rc.d/init.d/iptables restart ← restart iptables, the new rules take effect
Flushing firewall rules: [OK]
Setting chains to policy ACCEPT: filter [OK]
Unloading iptables modules: [OK]
Applying iptables firewall rules: [OK]

● Start the samba services(including two daemons: smb nmb)
[root@localhost ~]# chkconfig smb on ← set samba self-startup
[root@localhost ~]# chkconfig -list smb ← confirm the samba startup tab status, 2-5 are on
smb 0: off 1: off 2: on 3: on 4: on 5: on 6: off
[root@localhost ~]# chkconfig nmb on ← set from the start nmb
[root@localhost ~]# chkconfig -list nmb ←confirm the samba startup tab status, 2-5 are on
 (test found that even if all of them are off does not affect the samba service)
nmb 0: off 1: off 2: on 3: on 4: on 5: on 6: off
[root@localhost ~]# /etc/rc.d/init.d/smb start ← start the samba service
Starting SMB services: [OK]
[root@localhost ~]# /etc/rc.d/init.d/nmb start ← start nmb service
Starting NMB services: [OK]

● Windows access to samba server
Input //192.168.0.8 (samba server IP) in run can access the samba shared directory.

【※】

Q1:Although everything is OK, clients often access exception (unable to successfully log in or can see but can not access shared folders, etc.):
1st reason: Fedora firewall does not open samba port.
2nd reason: cause federa SELinux security subsystem, you can turn it off.
[root@localhost ~]# setenforce 0 ← set SELinux off

 

Q2:When  login samba in windows , windows warns that does not allow multiple users to access same share in samba .
Solution : I nputting  the command line  "net use * / del / y" in windows run , re- login samba.
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值