728x90
1. samba 폴더 설정
# vi /etc/samba/smb.conf 에서 추가할 samba 폴더 설정
[shared] ## samba 폴더 이름
comment = Shared directories
path = ${공유할 경로}
browseable = yes
guest ok = yes
public = yes
read only = yes
create mask = 644
directory mask = 755
writeable = yes
preserve case = yes
short preserve case = yes
2. 내부망에서 samba 폴더 mount 하기
# username, password 사용
mount -t cifs -o vers=3.0 -o username=${username},password=${password} //${ip_address}/shared ${mount_point}
# credentials 사용
mount -t cifs -o vers=3.0 -o credentials=${credential_file_path} //${ip_address}/shared ${mount_point}
## credentials 파일 내용 (권한 600)
username=${username}
password=${password}
# mount 잘 됐는지 확인
mount | grep cifs
//${ip주소}/shared on ${mount_point} type cifs (rw,relatime,vers=3.0,cache=strict,username=${username},uid=0,noforceuid,gid=0,noforcegid,addr=${ip주소},file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)
3. 외부망에서 samba 폴더 mount 하기
- samba는 139, 445(tcp) 포트와 137, 138(udp) 포트를 사용함
더보기
root@server:~# cat /etc/ufw/applications.d/samba
[Samba]
title=LanManager-like file and printer server for Unix
description=The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.
ports=137,138/udp|139,445/tcp
[Samba]
title=LanManager-like file and printer server for Unix
description=The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.
ports=137,138/udp|139,445/tcp
- 관련 포트 방화벽 해제하기 (ufw allow Samba를 하면 관련 포트 모두 방화벽 해제됨)
root@server:~# ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
root@server:~# ufw allow 'Samba'
Rules updated
Rules updated (v6)
root@server:~# ufw status
Status: active
To Action From
-- ------ ----
(.....)
Samba ALLOW Anywhere
Samba (v6) ALLOW Anywhere (v6)
- 위 4개 포트 포트포워딩해주기
- 단, 139 포트는 보안때문에 통신사에서 block 하는 경우가 있다고 하여 139가 아닌 포트로 포워딩
- ex. 내부포트 139 , 외부포트 8139
- 출처 https://cafe.naver.com/pogolinux/505
- samba 폴더 mount 하기
user1@client-server:~$ sudo mount -t cifs -o vers=3.0 -o username=${username},password=${password},port=8139 //${외부ip}/shared ${mount_point}
# mount 잘 됐는지 확인
user1@client-server:~$ mount | grep cifs
//${외부ip}/shared on ${mount_point} type cifs (rw,relatime,vers=3.0,cache=strict,username=${username},uid=0,noforceuid,gid=0,noforcegid,addr=${외부ip},file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=65536,wsize=65536,bsize=1048576,echo_interval=60,actimeo=1)
728x90
'Linux' 카테고리의 다른 글
[linux] iperf3: error - unable to connect to server: Connection timed out (0) | 2022.12.01 |
---|---|
/dev/ttyUSB* 에러 별 해결 방법 (0) | 2022.11.17 |
[linux] cifs_mount failed w/return code (0) | 2022.10.18 |
[linux] 일반 사용자에게 sudo, root 권한 부여 (0) | 2022.10.17 |
[linux] ADB server didn't ACK 해결방법 (0) | 2022.10.11 |