Samba server introduction, configuration and Windows and Linux access

1. Introduction

1.1 The origin of Samba

For windows network neighbors, the way to share files is the SMB and CIFS protocol, and the NETBIOS protocol between Linux/Unix uses the NFS protocol.
However, Linux and Windows cannot be shared, so Andrew Tridgell of the Australian National University decided to develop a software for sharing files between different systems, so a software called SMB turned out to be It was born, but this name cannot be registered as a trademark, because there is already an SMB agreement, so the author adds two A to the name, and it becomes the powerful file sharing server we will use: SAMBA.

1.2 What is Samba

Samba is a software that allows Linux systems to use the Microsoft network communication protocol, and SMB is the abbreviation of Server Message Block, which is the server message block. SMB is mainly used as Microsoft's network communication protocol. Later, Samba applied the SMB communication protocol to the Linux system. After that, the current Samba software was formed. Later, Microsoft renamed SMB to CIFS (Common Internet File System), that is, the public Internet file system, and added many new functions. In this way, Samba has more powerful functions.

1.3 Features of Samba

The biggest function of Samba is that it can be used for direct file sharing and print sharing between Linux and windows systems. Samba can be used for file sharing between windows and Linux, and it can also be used for resource sharing between Linux and Linux. Because of NFS( Network file system) can well complete the data sharing between Linux and Linux, so Samba is more used for data sharing between Linux and windows.

1.4 How Samba works

SMB is based on a client/server protocol, so a Samba server can act as a file sharing server or a Samba client. For example, a Samba server that has been set up under Linux, the windows client The resource files on the Samba server can be shared through the SMB protocol. At the same time, the Samba server can also access files shared by other windows systems or Linux systems on the network.
In fact, just like NFS is based on the RPC Server, the SAMBA file system is developed based on the NetBIOS (Network Basic Input/Output System, NetBIOS) communication protocol.
Samba uses the NetBIOS protocol under windows. If you want to use the files shared under Linux, please confirm whether the NetBIOS protocol is installed under your windows system.
There are two services that make up Samba to run, one is SMB, the other is NMB; SMB is the core startup service of Samba, which is mainly responsible for establishing the dialogue between Linux Samba server and Samba client, verifying user identity and providing file and printing For system access, only the SMB service is started to realize file sharing and monitor TCP port 139; while the NMB service is responsible for resolution, similar to the function implemented by DNS, NMB can associate the name of the working group shared by the Linux system with its IP , If the NMB service is not started, you can only access the shared files through IP, listening on UDP ports 137 and 138.

1.5 damons used by Samba

Communication between NetBIOS machines
Obtain the NetBIOS name of the host of the
other party. Locate the host: Use the authority granted by the other party to access the available resources.
SAMBA uses the following two services to control the above two steps, namely:
nmbd

  • This daemon is used to manage the resolution of workgroups, NetBIOS names, etc.
  • Mainly use UDP protocol to open port 137 138 to be responsible for the task of name resolution.

smbd

  • This daemon is mainly used to manage the directories, files, printers, etc. shared by the SAMBA host.
  • The reliable TCP protocol is mainly used to transmit data, and the open port is 139.
  • So at least this daemon is required every time SAMBA is started, and when I start SAMBA, the host system will start the two UDP
    ports 137,138 and the TCP port 139.

1.6 Introduction to Samba Online Mode

The two most common LAN connection modes
peer/peer (peer-to-peer mode)
domain model (master mode)

1.6.1 peer/peer (workgroup model, peer-to-peer model)

Insert picture description here
The advantage of using peer/peer architecture is that each computer can operate independently without being influenced by others! However, the disadvantage is that when all the people in the entire network have to share data, just knowing the account numbers and passwords in all computers will be very troublesome! Therefore, the Peer/Peer structure is more suitable: a
small domain
does not require a network environment that often requires file data sharing.
Each user owns the computer alone.

1.6.2 domain model (master control mode)

Insert picture description here
Place all accounts and passwords on a Primary Domain Controller (PDC). In my domain, when anyone wants to use any computer, they need to enter the account and password on the front of the screen, and then Appropriate permissions can only be granted after identification by the PDC server. In other words, different identities also have different computer resource permissions.

1.7 Common applications of Samba

What can Samba do?

  • Sharing files and printer services
  • It can provide the user's identity authentication when logging in to the Samba host to provide individual data of different identities.
  • Can perform host name resolution on the windows network

  • Application examples of Samba server that can share devices :
  • Use software to directly edit the web page data on the WWW host
  • Use FTP to modify and upload; it is inconvenient, it is very possible to upload the old version.
  • Online modification and comparison can quickly see the results.
  • Make a file server that can be connected directly
  • Because each person logs in with a different account name, the permissions on the directory are also different to achieve permission control.

Second, department

# 安装
yum -y install samba* #安装系列程序

samba-common //Mainly provides the samba server's setting file and the setting file syntax check program testparm
samba-client //Client software, mainly provides the tool instruction set needed when the linux host is used as the client
samba-swat //based on https Protocol samba server web configuration interface
samba
// server-side software, mainly provides samba server daemon, shared documents, log rotation,
boot default option Samba server is installed, it will generate configuration file directory /etc/samba and others Samba
executable command tool, /etc/samba/smb.conf is the core configuration file of samba.

rpm -qa | grep samba #查看samba程序的安装情况

Insert picture description here

# 启动服务
systemctl start smb #启动服务
systemctl enable smb #使能服务
systemctl status smb #查看服务状态

Insert picture description here

# 防火墙要求(若未开启防火墙,则不需要做以下设置,可先查看防火墙是否开启)
getenforce #若结果为Disabled,则说明未开启防火墙
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
getenforce 
# 操作系统普通用户(root) 转化为samba用户
id root #查看root用户信息
smbpasswd -a root #添加具有读写操作权限的root用户到samba服务中
pdbedit -L #查看samba服务允许的用户列表

Reminder: The
cloud server must enable the security group settings of port 139 and 445
Insert picture description here
Insert picture description here

Three, visit

3.1 Windows access

The first step: Control panel, uninstall the program, turn on or off the windows function in the upper left corner, and turn on the smb function of windows.
Insert picture description here
After that, you need to restart the computer.
Step 2: Add network mapping.
Insert picture description here
Enter the root account and password to access

3.2Linux access

Linux mount

sudo mkdir /release
#Create a folder to save the remote server sudo mount -o username=uesr,password=password //ip/root /release/ #mount operation

Guess you like

Origin blog.csdn.net/weixin_44704985/article/details/112389914