Lab environment: Virtual Machine + fedora9
Objective: To share samba with fedora9
Applicable to: cainiao who want to use shared resources on fedora9
I,
Samba
Introduction
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, allows different computers to share printers and files. 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.
II,
SambaDaemon
1. smbd
Listen 139
Set shared directory and print on TCP port
2. nmbd
137. 138 resolve UDP port management groups and NETBIOS
Here, we should note that based on security considerations, fedora9 separates SMB and nmb services. When we use the samba service, when the smb service is started, the nmb service will also be started. If fedora9 is not started, this will cause us to use [url = file: // ip/] \ IP [/url], but cannot be accessed using [url = file: // computer name/] \ computer name [/url, the solution is to start the SMB and nmb services at the same time.
III,
Software Installation
Run rpm-Qa | gerp Samba to check whether the samba software package is installed. If not, install the following software package.
# Rpm-IVH samba-3.2.0-1.pre3.9.fc9.i386.rpm
# Rpm-IVH samba-winbind-3.2.0-1.pre3.9.fc9.i386.rpm
# Rpm-IVH samba-common-3.2.0-1.pre3.9.fc9.i386.rpm
# Rpm-IVH samba-client-3.2.0-1.pre3.9.fc9.i386.rpm
# Rpm-IVH system-config-samba-1.2.63-1.fc9.noarch.rpm
Or you can use Yum install samba *-y.
IV,
Start the samba Service
# Service SMB start
(/Etc/init. d/SMB start) Start the smb service
# Service nmb start (/etc/init. d/nmb start) Start the nmb Service
You can also use chkconfig -- level SMB 35 on to set the startup level.
Let's check whether two services are started normally. Run the command pstree | grep MB.
If shown as follows, the instance is started normally:
|-Nmbd
|-Smbd --- 2 * [smbd]
|-Tomboy --- 2 * [{tomboy}]
V,
Configure the smb. conf file
Knowledge Point: Samba has four security levels:
Share: users can log on to the Samba server without the user name and need
User: You must enter the username and password to log on to the Samba server.
Server: Please check your own information, not frequently used, omitted
Domain: Please check your own information, not commonly used, omitted
For our dishes, we can use the user level. If you are lazy, you can use share
First, back up the configuration file smb. conf.
# Cp/etc/samba/smb. conf
/Etc/samba/smb. conf. Bak
Then, check whether your security = user is user. If it is share, change it to user.
# Vi/etc/samba/smb. conf
Workgroup = workgroup // set a Working Group
Server String = % u's samba % v // description % u indicates the current Login User
NetBIOS name = fedora // NetBIOS name. fedora9 is not enabled by default.
Log File =/var/log/samba/log. % m // log file storage PATH % m your Windows Host Name
Max log size = 50 // maximum log capacity
Security = user // security level. The user must have the user name and password, but not the share level.
[Share]
// Create a share named share
Comment = samba
// Description
Path =/tmp/share
// Shared path
Public = No // whether to allow access by the guest user (equivalent to guest OK = yes/no)
Writable = Yes // whether to write
Write list = lovehack // list of users that can be written (@ indicates the user group)
Create a shared directory and add permissions
# Mkdir/tmp/share
# Chmod 775/tmp/share
# Chown lovehack. lovehack/tmp/share
VI,
Add users and test sharing
Add a user accessing Samba and run the command smbpasswd-a username.
# Smbpasswd-A lovehack
// Lovehack is a user created in advance
Enter the password twice. Note that the password here is different from the password you log on to the system. It is only used to access the shared password.
Now we can test whether the configuration file is correct: testparm is generally correct.
Now we can use [url = file: // ip/] \ IP [/url] or [url = file: // computer name/] \ computer name [/url.
VII,
Solve the problem that SELinux in fedora9 denies access sharing.
In other versions of Linux (As5, as4, centos), after setting the above settings, you can access and share normally, but not in fedora9. We can only see sharing, however, access is denied. Why? Because SELinux imposes limits on Samba sharing, we only need to solve the limitations on Samba in SELinux. We can set the following settings to OK, this is also the purpose of my tutorial:
# Setsebool-P samba_enable_home_dir on
# Setsebool-P samba_export_all_ro on
# Setsebool-P samba_export_all_rw on
Run getsebool-A | grep Samba.
Check whether the preceding three items are enabled. If yes, your sharing will be normal.
Tutorial record: dedicated QQ: 59161949
My blog: http://hi.baidu.com/lovehack2006