centos7搭建samba文件共享服务器
前言
最近在学习centos 7,在这里记录一下,samba在windowns使用的是NetBIOS协议
Samba运行有两个服务,一个是smb,另一个是nmb
smb监听端口 TCP 139,NMB解析linux工作组名称与ip对应;
搭建samba文件共享服务器,实现linux与windows系统跨平台共享,samba支持各种异构服务器之间进行文件共享,功能比较多,不需要安装客户端
安装步骤
安装并启动samba
[root@Kling ~]# yum -y install samba #使用yum安装samba
[root@Kling ~]# systemctl start smb nmb #启动
[root@Kling ~]# systemctl enable smb #开机自启
[root@Kling ~]# systemctl enable nmb #开机自启
查看监听端口(smb监听TCP 139,445 | NMB监听,137,138端口)
[root@Kling ~]# netstat -anlpt | grep smb
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1610/smbd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1610/smbd
tcp6 0 0 :::445 :::* LISTEN 1610/smbd
tcp6 0 0 :::139 :::* LISTEN 1610/smbd
[root@Kling ~]# netstat -anlpu | grep nmb
udp 0 0 10.1.100.255:137 0.0.0.0:* 1622/nmbd
udp 0 0 10.1.100.250:137 0.0.0.0:* 1622/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 1622/nmbd
udp 0 0 10.1.100.255:138 0.0.0.0:* 1622/nmbd
udp 0 0 10.1.100.250:138 0.0.0.0:* 1622/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 1622/nmbd
3,防火墙放行samba
[root@Kling ~]# firewall-cmd --permanent --add-service=samba #放行samba服务
success
[root@Kling ~]# firewall-cmd --reload #重新加载防火墙
success
4,创建共享目录和用户
[root@Kling /]# mkdir /common
[root@Kling /]# useradd kouling
[root@Kling /]# smbpasswd -a kouling
[root@Kling /]# pdbedit -L #查看samba用户
kouling:1002:
修改配置文件
[common]
comment = ziliao
path = /common
allow hosts =10.1.100.0/24
writable = yes
语法检查
[root@Kling /]# testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
设置权限
[root@Kling /]# chown -R 755 /common/
重启服务
[root@Kling common]# systemctl restart smb
[root@Kling common]# systemctl restart nmb