Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration method of Samba Service and NFS Service under linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "Samba service and NFS service configuration method under linux". In the daily operation, I believe that many people have doubts about the configuration method of Samba service and NFS service under linux. The editor has consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the doubts of "Samba service and NFS service configuration method under linux". Next, please follow the editor to study!

I. Samba service configuration process

The function of samba is very simple, which is to enable sharing between linux and windows. And the use of samba to build a file server, not only more powerful than windows, but also fast and secure access. First of all, the samba server requires two daemons: smbd and nmbd. The smbd process listens on the 139TCP port and handles incoming SMB packets; the nmbd process listens on the 137and 138UDP port so that other hosts can browse the linux server.

1. Install the Samba service

First, use the command to test rpm-qi samba to see if the Samba package is installed, and if not, you can install it online with yum install samba (in fedora 11).

2. Start the Samba service

After the installation is complete, use the service smb start command to start the samba service. If you want the samba service to boot automatically, you can use the ntsysv command (or the system service option in the setup command) to turn on the boot auto-loading service, and check smb. After confirmation, you can boot and load the samba service.

3. Turn off the firewall

The firewall closes port 139 TCP by default, as well as ports 137,138 required by the nmbd process. So we use the command service iptables stop command to turn off the firewall. The firewall can also be modified to release TCP139 UDP 137,138 ports.

4. Configure samba service

The configuration file of the samba service is / etc/samba/smb.conf. Use the VI editor to open the vi / etc/samba/smb.conf file and configure samba.

The smb.conf file includes 4 structures, [Global], [Homes], [printers], and [Userdefined_shareName], where:

Globa is used to define global parameters and default values

Homes is used for home directory sharing of users

Printers is used to define printer sharing

Userdefined_ShareName is used for custom shares (there can be multiple)

Description: the beginning of the file with "#" as the description file, do not execute. It begins with ";" as an example file and does not execute (remove ";" if you want it to be executed).

Configure global parameters [Global]

◎ basic global parameters

Workgroup=MYGROUP sets the workgroup to which samba will join

Server string = Samba Service specifies the machine description in the browse list

Netbios name=fedora sets the NetBIOS name of samba (you need to add it yourself)

Client code page=936 sets the customer character code 936 to simplified Chinese (you need to add it yourself)

◎ log global parameters

Log file specifies the name of the log file

Max log size=50 specifies the maximum size of the log file (KB)

◎ security global parameters

Security defines the installation level of samba, and share-- users can log in to the samba server without a username and password; user-- is checked by the samba server providing samba services; the work of checking accounts and passwords by server-- is designated by another WindowsNT/2000 or samba server; domain-- assigns windowsNT/ 2000 domain controller to verify user accounts and passwords

Encrypt passwords = yes

Smbpasswd file = / etc/samba/smbpasswd

These two lines are used to set whether to encrypt the samba password and to specify the path to the encrypted file.

◎ configuration Custom Shar

To customize the sharing, you only need to add [share] at the end of the file and take whatever name you want. Let's introduce the parameters of one of them.

Comment describes the name of the share

Path defines the directory of the share

Browseable specifies whether the shared directory is browsable

Writable specifies whether the shared directory has write permission

Read only specifies that the directory of the share is read-only

Public specifies whether Guest account access can be allowed

Guest ok is the same as public, and yes is to allow guest access

Only guest specifies that only guest users can access

Calid users specifies the user who accesses the share

For example, comment = my share

Path = / home/share

Browseable = yes

Read only = yes

Public = yes

Only guest = yes

Work after ◎ configuration is completed

After the configuration is complete, we only need to create a new shared directory mkdir / home/share defined by path

And use the chmod command to set its permission to 777Jing chmod 777 / home/share.

This allows the client to access the server after service smb restart restarts the smb service (I modified the security=share in the global parameters, so there is no need to enter a user name and password to enter the server). Run under windows: / / 192.168.1.6 (the IP address of linux).

II. NFS service configuration process

1. Installation of NFS server

Check if nfs-utils and portmap packages are installed on the linux system, # rpm-Q nfs-utils (portmap)

2. Check whether the NFS server is started.

# service nfs status

# service portmap status

If the server is not started, the service is enabled (nfs is not fully enabled by default)

# service nfs start

# service portmap start

You can also turn off iptable and turn on nfs to start it automatically under the ntsysv command.

3. Specify the configuration file of the NFS server

The configuration file of the NFS server is saved in the "/ etc/" directory with the file name "exports", which is used for directory sharing provided by the alleged NFS server.

# vi / etc/exports

The configuration "exports" file format is as follows

/ tftpboot * (sync,ro)

Tftp: shared directory name

* indicates all hosts

(sync,ro) setting options

The configuration options field in the exports file is placed in a pair of parentheses ("()"), separated by commas between multiple options

Sync: set the NFS server to synchronize write disks so that data is not easily lost. It is recommended that all NFS shared directories use this option.

Ro: set the output of the shared directory to be read-only and cannot be used with rw

Rw: sets the shared directory of the output to be readable and writable, and cannot be used with ro

4. Re-output the shared directory

Exportfs management tools can manage "exports" files

# exportfs-rv allows the newly set "exports" file content to take effect

Displays the output list of NFS servers in the current host

# showmount-e

Displays the shared directory in the current host NFS server that has been mounted by the NFS client

# showmount-d

5. Mount the NFS file system using the mount command

# mount 192.168.1.6:/tftpboot / home/share

Mount the / tftpboot directory in the host IP address 192.168.1.6 to / home/share

Unmount the mounted NFS shared directory on the system

# umount / home/share

When uninstalling, you cannot uninstall it under the / home/share directory. You must log off the system and uninstall it.

At this point, the study on the configuration method of Samba service and NFS service under linux is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report