samba共享服务器配置文件,十.配置samba文件共享服务器

本文介绍了如何在Cobbler环境中安装Samba服务,包括软件包的安装、服务的启动与自启动设置,以及防火墙规则的配置以允许特定端口通信。步骤包括安装Samba客户端、启用服务、检查端口状态、调整iptables和为共享目录设置权限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.安装服务

#安装软件包

[root@cobbler downloads]# yum install -y samba samba-client samba-common

[root@cobbler downloads]# systemctl enable smb nmb

Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.

#启动smb/nmb服务并加入开机自启动

[root@cobbler downloads]# systemctl start smb nmb

[root@cobbler downloads]# systemctl status smb nmb

#查看smb/nmb的监听端口是否打开(smb服务端口TCP:139/445,nmb服务端口UDP:137/138)

[root@cobbler home]# netstat -anlpt |grep smb

tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 18825/smbd

tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 18825/smbd

tcp6 0 0 :::139 :::* LISTEN 18825/smbd

tcp6 0 0 :::445 :::* LISTEN 18825/smbd

[root@cobbler home]# netstat -anlpu | grep nmb

udp 0 0 172.17.255.255:137 0.0.0.0:* 18823/nmbd

udp 0 0 172.17.0.1:137 0.0.0.0:* 18823/nmbd

udp 0 0 192.168.28.255:137 0.0.0.0:* 18823/nmbd

udp 0 0 192.168.28.150:137 0.0.0.0:* 18823/nmbd

udp 0 0 0.0.0.0:137 0.0.0.0:* 18823/nmbd

udp 0 0 172.17.255.255:138 0.0.0.0:* 18823/nmbd

udp 0 0 172.17.0.1:138 0.0.0.0:* 18823/nmbd

udp 0 0 192.168.28.255:138 0.0.0.0:* 18823/nmbd

udp 0 0 192.168.28.150:138 0.0.0.0:* 18823/nmbd

udp 0 0 0.0.0.0:138 0.0.0.0:* 18823/nmbd

[root@cobbler home]# history

#防火墙iptables(docker使用)放行端口

[root@cobbler home]# iptables -A INPUT -p tcp --dport 443 -j ACCEPT

[root@cobbler home]# iptables -A INPUT -p tcp --dport 137 -j ACCEPT

[root@cobbler home]# iptables -A INPUT -p tcp --dport 138 -j ACCEPT

[root@cobbler home]# iptables -A INPUT -p tcp --dport 139 -j ACCEPT

[root@cobbler home]# service iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]

[root@cobbler home]# systemctl restart iptables.service

[root@cobbler home]# systemctl status iptables.service

● iptables.service - IPv4 firewall with iptables

Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)

Active: active (exited) since Fri 2019-08-09 10:14:42 CST; 11s ago

Process: 19228 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)

Process: 19290 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)

Main PID: 19290 (code=exited, status=0/SUCCESS)

Aug 09 10:14:42 cobbler systemd[1]: Starting IPv4 firewall with iptables...

Aug 09 10:14:42 cobbler iptables.init[19290]: iptables: Applying firewall rules: [ OK ]

Aug 09 10:14:42 cobbler systemd[1]: Started IPv4 firewall with iptables.

#创建共享目录以及添加用户

[root@cobbler downloads]# useradd turing

[root@cobbler downloads]# id turing

uid=1001(turing) gid=1001(turing) groups=1001(turing)

[root@cobbler downloads]# smbpasswd -a turing

New SMB password:

Retype new SMB password:

Added user turing.

#检测用户是否添加成功

[root@cobbler downloads]# pdbedit -L

turing:1001:

#给共享目录755权限授权

[root@cobbler home]# chmod -R 755 /home/downloads/

#修改配置文件

#检查配置文件语法

[root@cobbler home]# testparm

Load smb config files from /etc/samba/smb.conf

rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)

Processing section "[homes]"

Processing section "[printers]"

Processing section "[print$]"

Processing section "[downloads]"

Loaded services file OK.

Server role: ROLE_STANDALONE

#重启smb/nmb服务

[root@cobbler home]# systemctl restart smb nmb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值