Centos6.8安装配置samba文件共享

1、关闭SELinux
1.1 查看SELinux状态命令:getenforce,enabled表示启用selinux防火墙,enforcing 表示强。
1.2 修改selinux配置文件:vim /etc/selinux/config,将SELINUX=enforcing改成SELINUX=disabled,保存后退出。
1.3 重启后生效。rebootlinux

2、iptables配置
#查看iptables现有规则
iptables -L -nios

#先容许全部经过
iptables -P INPUT ACCEPTvim

#清空全部默认规则
iptables -Fwindows

#清空全部自定义规则
iptables -X服务器

#全部计数器归0
iptables -Ztcp

#容许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPTide

#开放22端口 21(FTP) 80(HTTP) 443(HTTPS)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT测试

#samba相关端口
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
iptables -A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
#iptables -A INPUT -p tcp --dport 8089 -j ACCEPTunix

#容许ping
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
#容许接受本机请求以后的返回数据 RELATED,是为FTP设置的
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#其余入站一概丢弃
iptables -P INPUT DROP
#全部出站一概绿灯
iptables -P OUTPUT ACCEPT
#全部转发一概丢弃
iptables -P FORWARD DROPserver

#保存上述规则
service iptables save

3、samba安装&配置
首先须要配置共享文件夹的路径,这里配置的是 /home/work
一、安装
rpm -qa | grep samba
yum install samba
chkconfig smb on

二、配置
cp /etc/samba/smb.conf /etc/samba/smb.confbak
vi /etc/samba/smb.conf
[global]
diplay charset = gbk
unix charset = gbk
dos charset = gbk
workgroup = work
netbios name = work
server string = uc
security = user

[darwin]
comment = uc
path=/home/work/
create mask = 0664
directory mask = 0775
writeable = yes
valid users = work
browseable = yes

#添加用户
smbpasswd -a work

三、启动

smbd -D
#查看进程是否启动
ps auxf | grep smbd
netstat –npl 查看samba端口号,默认会使用13九、445两个端口号

四、本地测试
smbclient -L 127.0.0.1 -U work

mac:
command +k ; smb://ip_address

windows:运行输入:\Samba服务器的ip

相关文章
相关标签/搜索