사용환경

PC1 192.168.1.85
CPU : Intel(R) Core (TM) i5-2520M CPU @ 2.50GHz 2.50GHz
RAM : 4GB
HDD : 500GB
OS : Win 7 Ultimate K x64

VMware1 192.168.6.129
RAM : 1GB
HDD : 20GB
OS : CentOS 6.3
SAMBA Version 3.6.9-167.el6_5

VMware2 192.168.6.130
RAM : 512MB
HDD : 40GB
OS : Win XP

0. SAMBA

Linux에 파일 서버를 생성 하여 SMB 프로토콜을 이용하여 Linux 파일 시스템에도 윈도우에서 접근 가능하게 만듦.

쉽게 말해 윈도우에서도 이용 가능한 리눅스 파일 서버.

1. SAMBA 설치

yum -y install samba samba-client samba-common

 

 

smbd --version

상기 명령어로 설치된 버전 확인 가능

Version 3.6.9-167.el6_5

2. SELINUX 설정

vi /etc/selinux/config

SELINUX 설정 값을 disabled 로 변경이 필요

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

변경 후 재부팅 필요

shutdown -r now
또는
init 6

3. 방화벽 설정

vi /etc/sysconfig/iptables

iptable에 하기 정책을 추가 할것

-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

추가 후 방화벽 재시작 필요

service iptables restart

4. SAMBA 설정

원본 파일 백업 후 진행 할것

cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
rm -f /etc/samba/smb.conf

vi 편집기로 파일을 생성 후 설정값 입력이 필요

vi /etc/samba/smb.conf  

 

[Global]
workgroup = WORKGROUP
security = share
map to guest = bad user

5. Share 공유 폴더 설정

디렉토리 생성 후 퍼미션 부여

mkdir -p /data/samba/share
chmod -R 777 /data/samba/share

Share 폴더에 대한 SAMBA 설정 값 추가 입력

vi /etc/samba/smb.conf

 

[Share]
path = /data/samba/share
browsable = yes
writable = yes
guest ok = yes
read only = no

6. User 공유 폴더 설정

유저 계정 생성

useradd -M sambauser
passwd sambauser
smbpasswd -a sambauser

디렉토리 생성 후 퍼미션 부여

mkdir -p /data/samba/user
chmod -R 777 /data/samba/user

User 폴더에 대한 SAMBA 설정 값 추가 입력

vi /etc/samba/smb.conf

 

[User]
path = /data/samba/user
browsable =yes
writable = yes
write list = sambauser
directory mask = 0777

7. Group 공유 설정

그룹 계정 생성

groupadd smbgrp
useradd -M -G smbgrp smbgrpuser1
passwd smbgrpuser1
smbpasswd -a smbgrpuser1

디렉토리 생성 후 소유권 부여

mkdir -p /data/samba/group
chown -R smbgrpuser1:smbgrp /data/samba/group

Group에 대한 SAMBA 설정 값 추가 입력

vi /etc/samba/smb.conf

 

[Group]
path = /data/samba/group
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes
directory mask = 0777

8. testparm 테스트

testparm

하기와 같은 메세지를 볼 수 있다.

Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[Share]"
Processing section "[User]"
Processing section "[Group]"
WARNING: The security=share option is deprecated
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
 security = SHARE
 map to guest = Bad User
 idmap config * : backend = tdb

 directory mask = 0777
 path = /data/samba/share
 read only = No
 guest ok = Yes

[User]
 path = /data/samba/user
 write list = sambauser
 read only = No
 directory mask = 0777

[Group]
 path = /data/samba/group
 valid users = @smbgrp
 read only = No
 directory mask = 0777

9. SAMBA 서버 재시작

service smb restart
service nmb restart

10. 접속 테스트

윈도우의 실행창에 SAMBA 서버의 IP로 접속이 가능하다.

실행창 -> \\192.168.6.129

 

참고 사이트

http://www.samba.org/samba/docs/man/Samba-Guide/ExNetworks.html

http://blog.beany.co.kr/archives/2273

http://openyouri.tistory.com/169

http://anti1346.egloos.com/v/4863483

 

 

 

by ARuKe 2014. 2. 18. 18:43