1. Install the samba service in CentOS6.3
Yum-y install smaba
2. Edit the samba configuration file
Vi/etc/samba/smb. conf
vi /etc/samba/smb.conf
1) Change the user group
Workgroup = WORKGROUP
workgroup = WORKGROUP
2) authorized IP addresses
Hostsallow = 127.192.168.1.
hosts allow = 127. 192.168.1.
3) set the Sharing Mode
Security = share
security = share
Three sharing methods
Password required in user mode
Share anonymous sharing
Server is more advanced than user-level security
4) set the Access Directory
[Www]
Comment = Documentrootdirectory
Path =/var/www/html
Public = yes
Writable = yes
Guestok = yes // anonymous access is allowed. If this parameter is not set, anonymous access is not allowed.
[Www] comment = Document root directory path =/var/www/html public = yes writable = yes guest OK = yes // anonymous access is allowed. If this parameter is not set, anonymous access fails.
3. Configure Firewall policies
- Vi/etc/sysconfig/iptables
vi /etc/sysconfig/iptables
1) Add the samba Port
- -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport139-jACCEPT
- -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport445-jACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
2) restart the Firewall Service
Serviceiptablesrestart
service iptables restart
Appendix:
1) view the service port
Netstat-anp | grepsmb
- [Root @ localhost ~] # Netstat-anp | grepsmb
- Tcp000.0.0.0: 1390.0.0.0: * LISTEN1874/smbd
- Tcp000.0.0.0: 4450.0.0.0: * LISTEN1874/smbd
- Tcp00: 139: * LISTEN1874/smbd
- Tcp00: 445: * LISTEN1874/smbd
- Unix2 [] dgram123161874/smbd
netstat -anp | grep smb[root@localhost ~]# netstat -anp | grep smbtcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1874/smbd tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1874/smbd tcp 0 0 :::139 :::* LISTEN 1874/smbd tcp 0 0 :::445 :::* LISTEN 1874/smbd unix 2 [ ] DGRAM 12440 1874/smbd
2) Disable The selinux Method
- [Root @ localhost ~] # Sestatus
- SELinuxstatus: enabled
[root@localhost ~]# sestatusSELinux status: enabled
[Root @ localhost ~] # Vi/etc/sysconfig/selinux
[root@localhost ~]# vi /etc/sysconfig/selinux
Change SELINUX = disabled
SELINUX = disabled
Restart machine $ reboot