yum install samba system-config-samba samba-client samba-common
mkdir -p /data0/public/
chmod 777 /data0/public/
mv -f /etc/samba/smb.conf /etc/samba/smb.conf.bak
vi /etc/samba/smb.conf
输入以下内容:
[global]
server string = Samba Server
security = share
hosts allow = 127.0.0.1 192.168.0.0/24 192.168.1.0/24
hosts deny = 0.0.0.0/0
[public]
path = /data0/public
public = yes
guest ok = yes
create mode = 0777
directory mode = 0777
browseable = yes
writable = yes
security = share
/sbin/service smb start
Samba服务所使用的端口和协议:
* Port 137 (UDP) - NetBIOS name service and nmbd
* Port 138 (UDP) - NetBIOS datagram service
* Port 139 (TCP) - File and printer sharing and smbd
* Port 389 (TCP) - for LDAP (Active Directory Mode)
* Port 445 (TCP) - NetBIOS was moved to 445 after 2000 and beyond, (CIFS)
* Port 901 (TCP) - for SWAT
开放防火墙:
/sbin/iptables -I INPUT -p udp --dport 137 -j ACCEPT
/sbin/iptables -I INPUT -p udp --dport 138 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 139 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 389 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 445 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 901 -j ACCEPT
service iptables save
关闭SELinux,不然会出现"您可能没有权限使用网络资源"的问题
setenforce 0
如果要启用,可以使用setenforce 1
这样就可以在win中使用\\x.x.x.x进行共享访问了
断开 samba ,运行:
net use * /del