阿里云CentOS7 Samba安装
2016-05-29 13:30
381 查看
[阿里云服务 CentOS7 Samba安装]
因为阿里云CentOS7服务器默认的防火墙是firewalle,且samba和vsftp相关端口都是关闭的
先安装iptables 配置相关rule, 然后配置samba。
PS:结合大家的分享整理一下自己安装过程。
一、iptables 配置
1、安装iptables
#先检查是否安装了iptables
service iptables status
#安装
yum -y install iptables
#升级
yum update iptables
#安装 iptables-services
yum -y install iptables-services
2、禁用/停止自带的firewalld服务
systemctl stop firewalld
systemctl mask firewalld
3、添加&保存iptables 规则
#查看iptables现有规则
iptables -L -n
#先允许所有,不然有可能会杯具
iptables -P INPUT ACCEPT
#清空所有默认规则
iptables -F
#清空所有自定义规则
iptables -X
#所有计数器归0
iptables -Z
#允许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPT
#开放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 ACCEPT
#允许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 DROP
#保存上述规则
service iptables save
4、开启iptables服务
#注册iptables服务 相当于chkconfig iptables on
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service
二、samba安装&配置
1、安装
rpm -qa | grep samba
yum install samba
chkconfig smb on
2、配置
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
3、启动
smbd -D
#查看进程是否启动
ps auxf | grep smbd
netstat –npl 查看samba端口号,默认会使用139、445两个端口号
4、本地测试
smbclient -L 127.0.0.1 -U work
mac:
command +k ; smb://ip_address
windows:
运行输入:\\Samba服务器的ip
【参考】
http://www.cnblogs.com/suihui/p/4334224.html http://www.cnblogs.com/kreo/p/4368811.html https://www.aliyun.com/zixun/content/3_12_518183.html
因为阿里云CentOS7服务器默认的防火墙是firewalle,且samba和vsftp相关端口都是关闭的
先安装iptables 配置相关rule, 然后配置samba。
PS:结合大家的分享整理一下自己安装过程。
一、iptables 配置
1、安装iptables
#先检查是否安装了iptables
service iptables status
#安装
yum -y install iptables
#升级
yum update iptables
#安装 iptables-services
yum -y install iptables-services
2、禁用/停止自带的firewalld服务
systemctl stop firewalld
systemctl mask firewalld
3、添加&保存iptables 规则
#查看iptables现有规则
iptables -L -n
#先允许所有,不然有可能会杯具
iptables -P INPUT ACCEPT
#清空所有默认规则
iptables -F
#清空所有自定义规则
iptables -X
#所有计数器归0
iptables -Z
#允许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPT
#开放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 ACCEPT
#允许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 DROP
#保存上述规则
service iptables save
4、开启iptables服务
#注册iptables服务 相当于chkconfig iptables on
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service
二、samba安装&配置
1、安装
rpm -qa | grep samba
yum install samba
chkconfig smb on
2、配置
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
3、启动
smbd -D
#查看进程是否启动
ps auxf | grep smbd
netstat –npl 查看samba端口号,默认会使用139、445两个端口号
4、本地测试
smbclient -L 127.0.0.1 -U work
mac:
command +k ; smb://ip_address
windows:
运行输入:\\Samba服务器的ip
【参考】
http://www.cnblogs.com/suihui/p/4334224.html http://www.cnblogs.com/kreo/p/4368811.html https://www.aliyun.com/zixun/content/3_12_518183.html
相关文章推荐
- CentOS 7中没有ifconfig命令,而且不能发现eth0
- Linux(CentOS6.5)下编译Popt报错”GNU gettext is required. The latest version”(gettext已经编译安装,但是没有安装在默认目录)的解决方案
- Unix & Linux 笔记(12)
- java 开发linux常用命令
- centos 大文件操作
- linux排错-思想篇
- 嵌入式linux启动过程
- linux下安装mysql5.7
- CentOS7 根目录扩容
- Unix & Linux笔记(11)
- centos6.5 下安装nmap,sqlmap
- centos7下搭建nexus
- linux-Python升级安装
- linux生成随机密码
- Linux I2C子系统分析之(一) ----- 用GPIO模拟I2C总线
- CentOS系统配置.ssh遇到port 22:No route to host问题的解决方法
- type命令及Linux命令类型
- linux vim注释
- Linux 1day
- Linux定时任务crontab