Linux networking entry (4): File Server

Source: Internet
Author: User
Article Title: Linux networking entry (4): file server. 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.
On a network, there may not only be LINUX systems, but also other operating systems such as Windows NT and Windows 95. How can we share file-level resources with machines with different operating systems? Next we will discuss this issue together.
  
9.1 make LINUX a file server-install the Samba server
  
9.1.1 what is Samba
Samba can be considered as a file server on a LAN. It can provide file services and printing services for customers in the same network (such as Win95 and WinNT. That is to say, the Samba server enables LINUX to implement functions provided by file servers like Novell Netware.
  
9.1.2 how Samba works
The working principle of Samba is to run NETBIOS (Communication Protocol of Windows95 network neighbor) and SMA (Server Message Block) protocols on TCP/IP communication protocol, in addition, the NETBEUI protocol of Windows 95 enables LINUX to be seen by Windows 95 on network neighbors.
The most important protocol is the SMB protocol (Server Message Block), which is used to share printers, serial ports, and abstract communication (such as Named Pipes and mail slots) between different computers. SMB is a very important protocol, which is widely used in all Microsoft Windows operating systems.
Samba is the implementation of SMB servers on UNIX-like systems. It is open-source GPL free software. Currently, Samba can run on almost all UNIX variants.
  
9.1.3 install the Samba server
In the RedHat LINUX operating system, if Samba is selected during installation, it will install Samba while installing LINUX. If you do not have any options, you can also find the Samba RPM installation package on the disc and use RPM to install it.
  
9.1.4 configure Samba
The job of configuring Samba is to set the configuration file smb. conf. Smb. conf is related to Samba server permission settings, as well as various detailed options such as shared directories, printers, and working groups of machines.
The syntax of file smb. conf is very clear. The file is divided into segments. The names of each segment are enclosed in square brackets. Set parameters in the format of "name = value" in each segment. The first plus sign indicates that the sentence is a comment. In the subsequent sections, we will only describe the most common and basic sections. For more in-depth settings, please read the comments in this document.
The configuration file contains three special segments.
1. Global segment: configure the parameters used by the server throughout the process, and provide default values for other segments.
[Global]
Workgroup = MYGROUP;
Hosts allow = 192.168.1. 192.168.2. 127.
Printcap name =/etc/printcap
Load printers = yeslog
File =/var/log/samba/log. % m
1) The first workgroup is used to specify the working group where the machine is located in the network neighbor. The default value is MYGROUP. You can modify it based on your preferences.
2) hosts allow is a description used to specify which machines in the LAN can use the Samba service. Generally, you do not need to set this parameter. Therefore, you can start with ";" to comment out this sentence.
3) The third sentence tells Samba where the printer name is located.
4) The fourth line load printers = yes indicates that the Samba server is allowed to browse all the printers.
5) The last sentence specifies the storage address of log files.
2. Homes segment: this segment is used to indicate the main directory of the user that allows the client to connect. The smb. conf file does not contain the specific content of this directory. When a service request is sent, find this specific service in the other part of the smb. conf file. If this service is not found and the homes segment is provided, search for the password file to find the user's home directory. By breaking down the Homes segment, Samba enables the user's main directory to be used for sharing. The following are the basic settings for this section.
[Homes]
Comment = Home Directory
Browseable = no
Writable = yes
1) The comment specifies the shares that can be used by the client on the server.
2) browseable sets whether to display the directory of Samba in the network browsing table. We recommend that you change it to browseable = yes.
3) The last sentence indicates whether you have the write permission.
3. Printers segment: Set the printer sharing status. The sample is shown in the following table:
[Printers]
Comment = All printers
Browseable = no
Printable = yes
We recommend that you change browseable = no to browseable = yes.
Generally, the most basic settings have been made in the default smb. conf file, and can be applied in multiple situations without any modifications. Therefore, it is recommended that you do not need to modify it for beginners. Of course, if necessary, you can refer to the comment statement for some attempts.
That is to say, if you do not modify smb. conf, the client can use the most basic Samba service.
  
9.1.4 start the Samba server
There are two methods to start the Samba server. One is standalone and the other is Inted:
The startup method occupies the resource response speed
Standalone
Inted mode is less slow
We recommend that you use the Inted method to start the Samba server. Note that you cannot run the Samba server in two ways at the same time. Otherwise, the Samba service may become unhealthy. This method is also used by default.
1. Start Using Inted
When Samba is installed, the following lines are added to the/etc/services file:
Netbios-ns 137/tcp
Netbios-ns 137/udp
Netbios-dgm 138/tcp
Netbios-dgm 138/udp
Netbios-ssn139/tcp
Netbios-ssn139/udp
The following lines are added to the/etc/inetd. conf file:
Netbios-ssn stream tcp nowait root/usr/sbin/smbd
Smbdnetbios-ns dgram udp wait root/usr/sbin/nmdb
If you want to start it in one of the following ways, add a comment symbol "#" before them, and then execute the inetd command to make the modification take effect.
2. Start with Standalone
If you want to start in this way, add the following lines to the/etc/rc. d/rc. local file:
Echo "startingsamba Server ......"
/Usr/local/samba/bin/smbd? D-d1
/Usr/local/samba/bin/nmbd? D? D1? N LINUX
  
9.1.5 use the Samba Service
Taking Windows 9x as an example, we can find a new working group, MYGROUP,
This LINUX host is also available below. We can use the Samba service.
  
9.2 Network File System NFS
Select NFS when installing LINUX so that the service can be installed on the LINUX system. Then we can easily use it.
  
9.2.1 share LINUX Files
Sharing LINUX Files Through NFS is simple. You only need to modify the/etc/exports file. For example, we want to share the/home/nfstest directory with the machine 202.101.55.5 and grant it read and write permissions, you only need to write the following information to the/etc/exports file.
/Home/nfstest 202.101.55.5 (rw)
  
9.2.2 Mount shared files in LINUX
Next, if we can plug in/home/nfstest on the machine 202.101.55.5 (202.101.55.1. We only need to simply execute the command:
Mount? T nfs 202.101.55.1:/home/nfstest/mnt/nfstest
In this way, the/home/nfstest directory on 202.101.55.1 is mounted to the/mnt/nfstest directory of 202.101.55.5.
  
  
  
  
  
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.