Article Title: Use Samba to implement the file server function. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Summary
It is a good solution to use Linux to create file servers in Small and Medium networks and enterprise intranets. This article is a concise guide to build file servers using Samba.
Linux is an excellent operating system, especially its network functions. It can be easily connected to various operating systems to implement a variety of network services. Thanks to the high stability, reliability, and low price of the Linux system, it is favored by more and more users. Using Linux to create a file server is a good solution for small and medium-sized networks or enterprise intranets. For most clients in the enterprise intranet that use Windows, we can use Samba to implement the file server function.
Samba is a free software that implements the SMB (Server Message Block) Protocol on Linux and Unix. It consists of servers and client programs. Here we will only introduce the server program.
First, we will introduce some SMB protocols. The SMB protocol is an application protocol built on the NetBIOS protocol. It is a service based on two ports: TCP138 and 139. After NetBIOS appears, Microsoft uses NetBIOS to implement a network file/print service system. This system sets a file sharing protocol based on NetBIOS, which Microsoft calls SMB (Server Message Block) protocol. This protocol is used in Lan Manager and Windows Server systems to share printers and files between different computers. Therefore, to integrate Windows with Unix/Linux computers, the best way is to install software that supports SMB on Unix/Linux computers. In this way, you can use shared resources on Unix/Linux computers like Windows NT or Windows 2000 servers without changing the settings on Windows clients. Samba enables SMB to run on the NetBIOS protocol, and uses the NetBEUI protocol of Windows to allow Unix/Linux servers to be accessed on Windows Network neighbors.
Samba server programs can implement the following functions:
◆ File and print sharing;
◆ Explanation of the computer name and IP address;
◆ WINS service support;
◆ User permission settings (if used in combination with Quota in Linux, the user's disk space Quota can also be realized ).
Install
Samba can be installed in two ways:
1. Install the RPM package
Let's take Red Hat as an example:
Mount-t iso9660/dev/cdrom/mnt/cdrom
Cd/mnt/cdrom/RedHat/RPMS
Rpm-ivh Samba *. rpm
Or upgrade and install
Rpm-Uvh Samba *. rpm
After Samba is installed, you can see a directory such as/etc/samba, which stores Samba-related files, such as lmhosts, smb. conf, and smbpasswd. Smb. conf is the core of Samba. All function configurations are in this file. It has many different configuration options. To avoid confusion, we need to introduce some parameter settings that are essential for correct Samba operations. Before configuring this file, we will first introduce the environment variables in Samba.
% S indicates the Share Name;
% P indicates the shared home directory;
% U indicates the shared user name;
% G indicates the user's working group;
% U indicates the user name;
% G represents the active working group of the user in the current dialog;
% H indicates the user's shared home directory;
% V indicates the Samba server version;
% H indicates the Host Name of the Samba service machine;
% M indicates the client NetBIOS name;
% L indicates the server NetBIOS name;
% M indicates the host name of the client;
% N indicates the name of the NIS server;
% P indicates the Home Directory of the NIS service;
% I represents the IP address of the client;
% T indicates the current date and time of the system.
Run the cd command to enter the directory where smb. conf is located and start common text editors, such as vi and emacs.
1. Global settings for smb. conf
[Global]
# Workgroup = NT-Domain-Name or Workgroup-Name
Server string = MY Samba Server
Hosts allow = 192.168.1. 192.168.2. 127.
Printcap name =/etc/printcap
Load printers = yes/no
Printing = bsd
The first line tells Samba that we define the name or domain name of the working group where the Samba server is located; the second line tells Samba the description of the server. Next, you can set the network and Host IP addresses that can be accessed. In the preceding example, hosts with IP addresses 192.168.1.0/24, 192.168.2.1/24, and 127.0.0.0/8 are allowed to access the server. The next step is to get the description of the printer in the/etc/printcap file and set whether to share the printer automatically. The next line defines the print system type. The default value is bsd, and there are several Optional options, such as lprng, sysv, plp, bsd, aix, and hpux.
Log file =/var/log/samba/log. % m
Max log size = 0
The above two lines are definitions of Samba logs. The recorded file is stored in/var/log/samba/% m. log. The next one defines the size of the log file, in KB. If it is 0, the size is not limited.
2. Samba Security Settings
Samba does not use a standard Unix password to authenticate users. When Windows sends a password in plaintext, it sends the SMB/CIFS password in encrypted form, which is incompatible with the standard Unix password hash. In other words, Samba cannot use the standard Unix Password hash to verify that the Windows encrypted Password is correct. Fortunately, Samba provides many methods to synchronize these two databases. The following describes how to set Samba security.
Guest account = nobody
Security = user
Password server =
Encrypt passwords = yes/no
The first line defines the default Samba user account, which must be in/etc/passwd. The second row declares the Samba security level, which includes share, user, server, and domain. They correspond to the following authentication methods: share is not secure, and any user can access resources on the server without a user name or password; user is the default configuration of Samba, users are required to provide the user name and password for verification before accessing shared resources. The server and user security levels are similar, but the user name and password are submitted to another server for verification. If the submission fails, the password is returned to the user security level. The domain security level requires that a Windows domain Controller exist on the network. Samba submits the user name and password for verification. Note that this user must be the system account on the Linux machine. It is necessary to set password server only when security is set to server or domain. It can be a domain name or an IP address of a machine. Encrypt passwords specifies whether to encrypt the password. Samba itself has a password file/etc/samba/smbpasswd. If the password is not encrypted, the plaintext password is transmitted between the client and the server during verification.
The above two lines respectively set the file that stores the Samba user password to/etc/samba/smbpasswd, and the specified user ing file to/etc/samba/smbusers. If we specify a line of root = administrator in this file, and the client user is administrator, the connection will be treated as the user root.
3. Network and host Performance Settings
In addition to the above user permission settings, there are also performance designs for networks and hosts.
Include =/etc/smb. conf. % m
Specifies that different configuration files are used for connections to different machines. To manage and use/etc/samba/smb. conf. % m. The Samba variable is used to associate the configuration file with the NetBIOS name of the client to easily control the permissions and settings of these clients.
This is a number of network Socket parameters that can achieve the best file transmission performance.
Interfaces = 192.168.12.2/24 192.168.13.2/24
The interface option is particularly useful when the machine happens to have multiple network interfaces. It can specify the network interface on which the machine is used.
Remote announce = 192.168.1.255 192.168.2.44
The preceding command specifies where the synchronization information of the browsing list is obtained, for example, from 192.168.2.44 or the entire subnet.
4. system compatibility settings
OS level = 33
The above parameter value is an integer that determines whether nmbd has the opportunity to become the local main browser in the local broadcast regional working group. The default value is zero, which means that nmbd has no choice for browsing. If you want nmbd to have the opportunity to become the local host browser, you can set it to 33.
Domain master = yes/no
You can set the above parameters to make nmbd a domain controller, obtain the list of domains, and submit the list of the entire domain to a local browser.
Preferred master = yes/no
Preserve case = yes/no
Short preserve case = yes/no
Default case = lower/upper
Case sensitive = yes/no
The preceding Parameters specify whether nmbd is the primary browser in the Working Group. If yes is specified, a browser is selected when nmbd is started. The following items are case-sensitive when the user specifies whether to copy DOS Files. The default value is no, that is, no. The default value of all DOS Files is uppercase and lowercase. Therefore, this parameter is generally set to no.
5. Host name query settings
Basically, we can regard Wins as a local Dynamic DNS database. When Samba runs as a Wins server, every Windows-compatible machine on the same subnet registers its IP address and NetBIOS Name (also known as "computer name") with Samba "). This allows Windows machines to use the Wins database of Samba to request the IP address of a specific NetBIOS name.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service