本文是基于centos6.5
一、下载
yum -y install samba
Copy after login
二、配置
vim /etc/samba/smb.conf
Copy after login
配置内容
[homes] comment = Home Directories browseable = no writable = yes path = /data/app_info create mode = 0644 force create mode = 0644 directory mode = 0755 force directory mode = 0755 ; valid users = %S ; valid users = MYDOMAIN\%S
Copy after login
三、创建smba登录用户
sudo smbpasswd -a username
Copy after login
备注:这个username一定要存在,否则会报:Failed to add entry for user ‘username’.
终端执行上面的命令后会提示输入密码,如下:
New SMB password: Retype new SMB password:
Copy after login
四、防火墙设置:
iptables -I RH-Firewall-1-INPUT 5 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT iptables -I RH-Firewall-1-INPUT 5 -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT iptables -I RH-Firewall-1-INPUT 5 -p udp -m udp --dport 137 -j ACCEPT iptables -I RH-Firewall-1-INPUT 5 -p udp -m udp --dport 138-j ACCEPT
Copy after login
五、windows访问
\\122.92.85.116
Copy after login
提示输入刚刚设置的用户名和密码,ok。
外网想要能访问修改一下防火墙配置
-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 -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 -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 -s 10.0.0.0/8 -p tcp -m state --state NEW -m tcp --dport 137 -j ACCEPT #-A INPUT -s 10.0.0.0/8 -p tcp -m state --state NEW -m tcp --dport 138 -j ACCEPT #-A INPUT -s 10.0.0.0/8 -p tcp -m state --state NEW -m tcp --dport 139 -j ACCEPT #-A INPUT -s 10.0.0.0/8 -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT
Copy after login