1、查看是否已经安装samba服务器:rpm -qa| grep samba
samba-client: 客户端软件
samba-common: samba服务器的主文件
samba-4.1.1-31.el7.x86_64:服务器端软件
2、如果没有安装samba服务器端软件就插入U盘
a、挂载目录:mount /dev/sdb4 /mnt
b、进入到Packets文件夹下执行:ls -l | grep samba找到安装软件
c、测试安装软件samba-4.1.1-31.el7.x86_64.rpm是否有依赖性可以安装
rpm -ivh samba-4.1.1-31.el7.x86_64.rpm --test
d、如果测试成功就安装:
rpm -ivh samba-4.1.1-31.el7.x86_64.rpm
e、卸载U盘:umount /dev/sdb4
3、添加用户并修改密码:
useradd user
userpw user
4、设置user用户登录samba服务器的密码:
smbpasswd -a user
5、配置samba服务器: vim /etc/samba/smb.conf
配置内容如下(改内容添加在[homes]之前):
[root]
comment = root Directories
path = / //共享的目录
browseable = yes //是否允许浏览共享文件
writable = yes //是否允许写入
valid users = luowenbin //允许访问的用户名
6、运行testparm检查smb.conf文件是否配置正确
7、关闭selinux,修改配置为默认重启之后关闭selinux,以防止samba服务器在测试时出错。修改的配置文件/etc/selinux/config如下:
修改完成之后如不想重启可以使用:setenforce 0或者setenforce permissive命令停止selinux服务
查看SELinux状态:sestatus -v
8、清空iptables防火墙规则并保存至系统:
9、重启samba服务器并查看运行状态:
10、通过客户端进入samba服务器:
\\192.168.0.109
smb自启动可以在rc.local文件中添加service smb restart或者执行chkconfig smb on
重启电脑之后无法登陆samba服务器,原因是由于存在iptables,需要执行iptables -F
或者将samba服务添加到iptables中去。
查看iptables的iptables -L --line-number
添加规则以启动samba所使用的端口,要注意添加的规则需要在REJECT规则之前,否则无效。
查看添加之后的iptables:
最后保存iptables规则并重新启动samba服务器
但是上述操作完成之后,我重新启动linux系统,iptables表又回到了原始状态。原因不详。执行过一下的操作
在/etc/rc.d/rc.local中添加service iptables restart和iptables-restore < /etc/sysconfig/iptables等情况均无效,然后修改/etc/sysconfig/iptables-config 文件中的IPTABLES_MODULES_UNLOAD为no也是没有效果,通过chkconfig iptables on将iptables加入到自启动项中也没有效果。然后通过restart iptables 发现iptables.service文件并跟踪找到文件/usr/libexec/iptables/iptables.init,这个文件是执行service iptables 命令的具体文件,在这个文件中也没有发现导致重启linux之后为什么iptables表回到原始状态的原因。
最后在/root/.bashrc文件中添加service iptables restart,问题就解决了
上述就是整个samba服务器盘配置过程和自己遇到的问题,贴出来分享给大家同时还望大家多多指点。