您的位置:首页 > 运维架构 > Linux

samba服务器搭建

2016-04-10 21:19 274 查看
1、查看是否已经安装samba服务器:rpm -qa| grep sambasamba-client: 客户端软件samba-common: samba服务器的主文件samba-4.1.1-31.el7.x86_64:服务器端软件2、如果没有安装samba服务器端软件就插入U盘a、挂载目录:mount /dev/sdb4 /mntb、进入到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 --testd、如果测试成功就安装:rpm -ivh samba-4.1.1-31.el7.x86_64.rpme、卸载U盘:umount  /dev/sdb43、添加用户并修改密码:useradd useruserpw user
4、设置user用户登录samba服务器的密码:smbpasswd -a user5、配置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 -v8、清空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服务器盘配置过程和自己遇到的问题,贴出来分享给大家同时还望大家多多指点。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息