반응형
테스트한 날짜: 2024년 2월 20일

 

 

잠깐 !!
PPTP Server 구축하기 전에 PPTP Client 설정 및 터널 생성하는 법을 알고 싶다면 아래 문서를 참고 !

 

       https://andrewpage.tistory.com/257

 

 

PPTP 패키지 설치

$ sudo  apt install pptpd

 

 

PPTP 서버 설정

##
## Tunnel Interface에 할당할 IP address를 설정한다.
##   예를 들어, PPTP server는 ppp0 tunnel interface에 10.1.0.1 주소를 할당.
##            PPTP client는 ppp0 tunnel interface에 10.1.0.100 주소를 할당.
##

$ cat /etc/pptpd.conf
... 중간 생략 ...

localip 10.1.0.1
remoteip 10.1.0.100-130

... 중간 생략 ...


##
## PPTP client에 접속 요청할 때, PPTP server가 아래의 network 구성 정보를 client에게 전달하도록 함.
## mtu 값은 실제 physical NIC의 mtu 값보다 대략 60~100 bytes 정도 작게 설정해야
## tunnel session을 통해서 IP 패킷이 전송될 때, IP 패킷의 꼬리 부분이 짤리는 현상이 없다.
## 예를 들어서, physical NIC의 MTU 값이 1500 이라고 가정해보면
##   PPTP tunnel interface의 MTU는 1400 정도 되어야 IP packet이 버려지지 않고 전송된다.
## 만약 실수로 tunnel mtu를 1500으로 설정하면, 1500 byte 짜리 IP packet이 전송되려 할 것이고
## 이 때 IP packet의 뒷 부분 60~100 bytes 정도가 짤리는 현상이 발생할 것이다.
##

$ cat /etc/ppp/pptpd-options
... 중간 생략 ...

ms-dns 1.1.1.1
mtu 1400
mru 1400

default-asyncmap

... 중간 생략 ...


##
## 반드시 ip_forward를 enable 시켜야 한다.
## ip_forward 설정이 enable 되어야 한개의 Linux OS내부에서 Physical port 'ens3'와 ppp0 간에 패킷이 forward된다.
##

$  sudo sysctl -w net.ipv4.ip_forward=1

$  cat  /etc/sysctl.conf
... 중간 생략 ...

net.ipv4.ip_forward=1

... 중간 생략 ...

$

 

PPTP 계정 설정

PPTP client가 PPTP server에 접속할 때 사용할 Account 정보를 설정한다.

$ cat /etc/ppp/chap-secrets

# client        server  secret                  IP addresses
mynewid         pptpd   my!pass@word            *
gildong         pptpd   me!hahahoho@            *

 

 

PPTP 서비스 기동

$ systemctl start pptpd

$ systemctl enable pptpd

$ systemctl status pptpd
● pptpd.service - PoPToP Point to Point Tunneling Server
     Loaded: loaded (/lib/systemd/system/pptpd.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-02-20 22:35:17 KST; 34min ago
     
... 중간 생략 ...

 

 


PPTP Client를 이용하여 PPTP 터널 생성 테스트하기

Ubuntu OS에서 PPTP Client를 설정하는 방법은 아래 문서를 참고 !


     https://andrewpage.tistory.com/257

 

 

 


 

반응형

 


 

작성일: 2023년 12월 11일

 

 

Ubuntu 20.04 또는 Ubuntu 22.04에 Samba(SMB) 서버를 설치하고 싶다면 아래 절차를 따라하면 잘 동작한다.

  

 

##
##  Samba 서버 프로그램을 설치한다.
##
$  sudo apt-get install -y samba

...

##
##  Samba 서버가 공유할 폴더(디렉토리) 정보를 설정한다.
##
$  vi /etc/samba/smb.conf
... 중간 생략 ...
;
; 아래 내용을 추가한다.
;
[mybox]
   comment = My File Box
   path = /home/sejong
   guest ok = no
   browseable = yes
   writable = yes
   create mask = 0777
   directory mask = 0777
   valid users = sejong
... 중간 생략 ...

##
## Linux 계정 'sejong'을 samba 접근 계정으로 추가한다.
## 암호는 Linux 계정 'sejong'의 암호와 달라도 된다.
##
$  sudo smbpasswd -a sejong

##
## Samba 서버 데몬을 재기동한다.
##
$  sudo /etc/init.d/smbd restart
## 또는 위 명령을 아래와 같이 수행해도 된다.
##  $ sudo  systemctl restart smbd

 

클라이언트 PC에서 아래와 같이 Samba 서버에 접속시도한다. (아래는 Macbook에서 실행한 화면)

 

Macbook에서 Samba 서버에 접속 시도

 

 

 

 

Samba 서버 설정 끝 !!!
Samba 서버 관리 명령을 알고 싶다면, 아래 내용을 더 읽어보아요~~

 

 

 

Samba 계정 정보를 보고 싶다면, 아래와 같이 `pdbedit` 명령으로 조회할 수 있다.

 

$  pdbedit -L -v

---------------
Unix username:        sejong
NT username:
Account Flags:        [U          ]
Home Directory:       \\ANDREW-UBUNTU\sejong
HomeDir Drive:
Logon Script:
Profile Path:         \\ANDREW-UBUNTU\sejong\profile
Domain:               ANDREW-UBUNTU
Account desc:
Workstations:
Munged dial:
Logon time:           0
Logoff time:          Thu, 07 Feb 2036 00:06:39 KST
Kickoff time:         Thu, 07 Feb 2036 00:06:39 KST
Password last set:    Wed, 07 Dec 2022 16:06:30 KST
Password can change:  Wed, 07 Dec 2022 16:06:30 KST
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

$

 

 

Samba 서버에 접속한 Client 정보를 보고 싶다면 아래와 같이 `smbstatus` 명령을 사용한다.

$  smbstatus

Samba version 4.15.9-Ubuntu
PID     Username     Group        Machine                                   Protocol Version  Encryption           Signing
----------------------------------------------------------------------------------------------------------------------------------------
295419  sejong       sejong       10.1.3.169 (ipv4:10.1.3.169:63352)        SMB3_11           -                    partial(AES-128-CMAC)

Service      pid     Machine       Connected at                     Encryption   Signing
---------------------------------------------------------------------------------------------
mybox        295419  10.1.3.169    Wed Dec  7 04:23:23 PM 2022 KST  -            -


Locked files:
Pid          User(ID)   DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
295419       1001       DENY_NONE  0x100081    RDONLY     NONE             /home/sejong   .   Wed Dec  7 16:23:22 2022

 

 

계정 정보를 변경하고 싶다면,  `usermod` 명령을 사용한다.

 

$  usermod --help
Usage: usermod [options] LOGIN

Options:
  -b, --badnames                allow bad names
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                the user from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -v, --add-subuids FIRST-LAST  add range of subordinate uids
  -V, --del-subuids FIRST-LAST  remove range of subordinate uids
  -w, --add-subgids FIRST-LAST  add range of subordinate gids
  -W, --del-subgids FIRST-LAST  remove range of subordinate gids
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account

 

 

게시물 작성자: sejong.jeonjo@gmail.com

 

 


 

반응형

 

REST API Server

Go 기본 Package만 사용해서 REST API Server 만들기

일단, 아래 블로그가 예제 코드를 복사해서 실습하기 좋게되어 있다.

https://woony-sik.tistory.com/12

 

Golang REST API 만들기

오늘은 Golang으로 간단한 REST API를 만드는 방법을 쓸까 한다. 바로 시작하자 우선은 Directory를 하나 만들고 시작 mkdir rest go module 등록 go mod init noah.io/ark/rest main.go 생성 touch main.go Direc..

woony-sik.tistory.com

 

 

gorilla package의 mux를 이용해서 REST API Server 만들기

이 블로그는 자동 Test하는 Code까지 포함되어 있다.

따라서 상용 Software PKG 개발할 때, 참고하면 좋다.

 

https://velog.io/@soosungp33/Golang%EC%9C%BC%EB%A1%9C-%EC%9B%B9%EC%84%9C%EB%B2%84-%EB%A7%8C%EB%93%A4%EA%B8%B04

 

 

Golang으로 웹서버 만들기(4)

RESTful API - GET과 POST 다뤄보기

velog.io

 

 

 

REST API Client

go-resty 라는 'REST client library'를 이용하면, 쉽게 REST API Client App을 개발할 수 있다.

아래 GitHub에 Case by Case로 Example이 있기 때문에 장황한 설명보다는 아래 Web Docs에 있는 Example Code를 보고 이해하고 따라해보는 것이 좋을 듯하다.

https://github.com/go-resty/resty
 

GitHub - go-resty/resty: Simple HTTP and REST client library for Go

Simple HTTP and REST client library for Go. Contribute to go-resty/resty development by creating an account on GitHub.

github.com

 

go-resty를 소개한 블로그이다. 쉽게 설명했으니까 한번 읽어보면 좋을 것이다.

go-resty를 사용하면, JSON Type의 Request / Response 를 Marshal, Unmarshal할 필요가 없다.

 

https://wookiist.dev/104
 

[Go/Golang] Go의 HTTP & REST Client 라이브러리 - Resty

Go의 HTTP & REST Client 라이브러리 - Resty API Client 이전 포스팅에서 다뤘던 Echo는 Go의 Web Framework입니다. Echo로 구현한 프로그램은 API Server 등으로 동작할 수 있고, 큰 어려움 없이 Web Server로..

wookiist.dev

 

 

 

 

 

기타 Reference 하면 좋을 Blog

 

https://doitnow-man.tistory.com/259

 

[Go Lang] 4. 실전 - http server + swagger 만들기

목표 web framework를 사용하여 간단한 web api server를 만들어 보겠습니다. 배포는 추후 포스트에서 다루겠습니다. 개발 환경 - ubnutu 18.04 - go version go1.16.3 linux/amd64 (업그레이드 방법: golang.org..

doitnow-man.tistory.com

 

 

블로그 작성자: sejong.jeonjo@gmail.com

 

 

반응형

 

Netcat(nc) TCP, UDP를 통해 Peer(Client/Server) 연결하고, 데이터를 읽고 쓰는 유틸리티 프로그램이다.

 

대부분 개발자, 운영자가 아래와 같은 목적으로 NC 명령을 사용할 것이다.

 

1)  두 장비(Network Node) 간에 IP Network이 정상인지 확인하거나

2)  중간에 방화벽이 있다면, 방화벽 정책이 적용되었는지 직접 TCP, UDP 트래픽을 테스트하기 위해서 NC를 사용한다.

3)  서버 또는 클라이언트 한쪽만 개발(구현)한 뒤에 Peer를 시뮬레이션하기 위해서...  (즉, 시뮬레이터 만들기 귀찮아서 ㅋㅋ) 

 

 

 

설치

 

##
## Mac OS 에 설치하는 경우
##

$  brew install netcat


##
## Ubuntu 에 설치하는 경우
##

$  apt install -y netcat


##
## CentOS, Redhat 에 설치하는 경우
##

$  yum install -y nc

 

 

 

사용 방법 / 예제

 

장황하게 설명하는 것보다는 아래 화면 캡처 하나가 훨씬 이해하기 좋을 듯~~~

그냥 아래 화면처럼 따라하면 테스트가 잘 된다.

 

##
## Netcat Server
##

$  nc  -l  -p 9090


##
## Netcat Client
##

$  nc  10.10.5.3  9090

이것은 테스트 메시지이다. (enter key)
...
...
... 이런 식으로 메시지를 타이핑하면서 테스트한다 ...
...
...

^C

$

 

 

게시물 작성자: sejong.jeonjo@gmail.com

 

+ Recent posts