1 安装iptables防火墙
安装iptables和iptables-services
yum install iptables
yum install iptables-services
关闭centos自带的防火墙
systemctl stop firewalld
systemctl mask firewalld
2 清空防火墙默认规则和自定义规则
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
3 防火墙开放samba服务所需端口和常用端口
vi /etc/sysconfig/iptables
添加以下内容到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
-A INPUT -p tcp –dport 22 -j ACCEPT
-A INPUT -p tcp –dport 21 -j ACCEPT
-A INPUT -p tcp –dport 80 -j ACCEPT
-A INPUT -p tcp –dport 443 -j ACCEPT
-A INPUT -p icmp –icmp-type 8 -j ACCEPT
-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-P OUTPUT ACCEPT
4 开启iptables防火墙
注册iptables服务
systemctl enable iptablesservice
开启服务
systemctl start iptablesservice
查看状态
systemctl status iptablesservice
5 安装和配置samba
yum install samba
设置samba开机启动
chkconfig smb on
vim /etc/samba/smbconf,粘贴复制以下内容
[global]
unix charset = gbk
dos charset = gbk
workgroup = img
netbios name = img
server string = uc
security = user
smb ports = 1315 1314 #很重要,貌似阿里云屏蔽了samba默认的端口
[img]
comment = uc
path=/home/xuhaoguang/work
create mask = 0664
directory mask = 0775
writable = yes
valid users = work #登录samba服务的账号
browseable = yes
给samba添加work账号:
smbpasswd -a work
启动samba:
service smb restart
6 客户端连接samba服务
mac:
command +k ; smb://ip_address:1314
windows:
运行输入:\Samba服务器的ip
我是按照上面的步骤完成阿里云服务器上的samba配置的,仅供大家参考!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)