banner-image

Photo by Harrison Broadbent on Unsplash

์ €๋Š” AWS Lightsail๋กœ ๊ฐœ์ธ ์„œ๋ฒ„๋ฅผ ์ด์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•œ ์›น ์„œ๋น„์Šค๋‚˜ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ํ…Œ์ŠคํŠธ๋ฅผ ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š”๋ฐ์š”, ๊ฐ€์žฅ ์ž‘์€ ์ธ์Šคํ„ด์Šค๋ฅผ ์ด์šฉํ•ด๋„ ๋งค๋‹ฌ ์•ฝ 4.3๋‹ฌ๋Ÿฌ๊ฐ€๋Ÿ‰์˜ ๊ธˆ์•ก์ด ์ฒญ๊ตฌ๋ฉ๋‹ˆ๋‹ค. EC2์˜ t2.micro๊ฐ€ ๊ฐ€์žฅ ์ž‘์€ ์ธ์Šคํ„ด์Šค์˜€๋˜ ๋•Œ์— ๋น„ํ•˜๋ฉด ์ ˆ๋ฐ˜ ๊ฐ€๊ฒฉ์œผ๋กœ ์ €๋ ดํ•˜์ง€๋งŒ(2019-07-12 ์„œ์šธ ๋ฆฌ์ „ ๊ธฐ์ค€ ์•ฝ 10๋‹ฌ๋Ÿฌ/์›”), ๊ทธ๋ž˜๋„ ๋ณ„๋‹ฌ๋ฆฌ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ๋•Œ์—๋„ ์ง€์†์ ์œผ๋กœ ์ฒญ๊ตฌ๋˜๋Š” ๊ฒŒ ์•„๊น๊ฒŒ๋งŒ ๋Š๊ปด์ง‘๋‹ˆ๋‹ค.
๋•Œ ๋งˆ์นจ, ์ฑ…์ƒ ์˜† ๋ฐ•์Šค์— ๋‹ด์ ธ๊ฒจ์žˆ๋Š” ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด๊ฐ€ ๋ˆˆ์— ๋“ค์–ด์™”์Šต๋‹ˆ๋‹ค. ํ˜ธ๊ธฐ์‹ฌ์— ๊ตฌ์ž…ํ–ˆ๋˜ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด๋Š” 3 ๋ชจ๋ธ B+๋กœ 1.4GHz ์ฟผ๋“œ์ฝ”์–ด, 1GB RAM๋กœ ํ™ˆ ์„œ๋ฒ„๋ฅผ ๊ตฌ๋™ํ•˜๊ธฐ์—” ์ถฉ๋ถ„ํ•œ ์„ฑ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. (์‹ฌ์ง€์–ด ๋‹จ์ˆœ ๋น„๊ต๋งŒ ๋†“๊ณ  ๋ณด๋ฉด ๋‚ด๊ฐ€ ์‚ฌ์šฉํ•˜๋˜ 1์ฝ”์–ด, 512MB RAM์˜ Lightsail ์ธ์Šคํ„ด์Šค๋ณด๋‹ค ์‚ฌ์–‘์ด ์ข‹์Šต๋‹ˆ๋‹ค). ๋‚˜๋Š” ๊ณ ๋ฏผํ•  ํ•„์š”๋„ ์—†์ด ๋ฐ”๋กœ ํ™ˆ์„œ๋ฒ„ ๊ตฌ์ถ• ์ž‘์—…์— ๋“ค์–ด๊ฐ”์Šต๋‹ˆ๋‹ค.

์„œ๋ฒ„ ๊ตฌ์ถ• ์ „ ํ™•์ธ ํ•„์š” ์‚ฌํ•ญ

์™ธ๋ถ€์—์„œ ํ™ˆ ์„œ๋ฒ„์˜ 80, 443 ํฌํŠธ๋กœ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•œ๊ฐ€

80, 443 ํฌํŠธ๋ฅผ ์ด์šฉํ•œ ์›น ์„œ๋น„์Šค๋ฅผ ํ•  ๊ฒฝ์šฐ ๋ฐ˜๋“œ์‹œ ํ™•์ธํ•ด์•ผ ํ•˜๋Š” ์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค. ๊ฐ€์ •์šฉ ๊ณต์œ ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํฌํŠธ๊ฐ€ ๋ง‰ํžˆ๋Š” ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ ๋ฐ ์…‹์—…์€ ๋”ฐ๋กœ ์ ์ง€ ์•Š๊ฒ ์Šต๋‹ˆ๋‹ค. ์ด ๊ธ€์„ ์ฝ์œผ์‹œ๋Š” ๋ถ„๋“ค๊ป˜์„  ํฌํŠธ ํฌ์›Œ๋”ฉ, DMZ์„ ์ž˜ ํ•˜์‹œ๋ฆฌ๋ผ ๋ฏฟ์Šต๋‹ˆ๋‹ค.
๋ช‡๋ช‡ ISP(Internet service provider; ์ธํ„ฐ๋„ท ์„œ๋น„์Šค ์ œ๊ณต์ž)๋Š” ๊ฐ€์ •์šฉ ์ธํ„ฐ๋„ท์—์„œ ์„œ๋ฒ„ ์šด์˜์„ ๋ง‰๊ธฐ ์œ„ํ•จ์ธ์ง€ 80, 443 ๋“ฑ ์•Œ๋ ค์ง„ ํฌํŠธ๋ฅผ ๋ง‰๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์„œ๋ฒ„๋ฅผ ๋‹ค ๊ตฌ์ถ•ํ•œ ๋‹ค์Œ์—์„œ์•ผ ์ ‘์†์ด ์•ˆ๋œ๋‹ค๋Š” ๊ฒƒ์„ ๊นจ๋‹ซ๊ณ  ์ขŒ์ ˆํ•˜์ง€ ์•Š๋„๋ก ํฌํŠธ๊ฐ€ ์—ด๋ ค์žˆ๋Š”์ง€ ์ž‘์—… ์ „ ๋ฏธ๋ฆฌ ํ™•์ธํ•ด๋ด…์‹œ๋‹ค.

๋ฐฉ๋ฒ•์€ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค. ์ปดํ“จํ„ฐ์— ๊ฐ„๋‹จํ•œ ์›น ์„œ๋ฒ„๋ฅผ ๋„์šฐ๊ณ , ์™ธ๋ถ€๋ง(์˜ˆ: LTE๋กœ ์—ฐ๊ฒฐ๋œ ์Šค๋งˆํŠธํฐ)์œผ๋กœ ์„œ๋ฒ„์— ์ ‘์†์„ ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค. ์›น ํŽ˜์ด์ง€๊ฐ€ ์ž˜ ๋กœ๋“œ๋˜๋ฉด ํฌํŠธ๊ฐ€ ์—ด๋ ค์žˆ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

  1. ์ธํ„ฐ๋„ท ๋ชจ๋Ž€(๊ฒธ ๊ณต์œ ๊ธฐ)์— ์ปดํ“จํ„ฐ๋ฅผ ์ง์ ‘ ์—ฐ๊ฒฐํ•˜์—ฌ ๊ณต์ธ IP๋ฅผ ํ• ๋‹น๋ฐ›์Šต๋‹ˆ๋‹ค.
  2. ๊ฐ„๋‹จํ•œ ์›น์„œ๋ฒ„๋ฅผ ๋Œ๋ ค๋ด…์‹œ๋‹ค. Python http.server ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•˜์—ฌ โ€œHelloโ€๋ผ๊ณ  ์ ํžŒ index.html์„ ํ˜ธ์ŠคํŒ… ํ•ด๋ด…์‹œ๋‹ค.
$ mkdir www; cd www
$ touch index.html
$ echo Hello > index.html
$ python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

์ด์ œ ์Šค๋งˆํŠธํฐ ๋“ฑ์„ ์ด์šฉํ•ด ์™ธ๋ถ€๋ง์—์„œ ์ ‘์†์„ ์‹œ๋„ํ•ด๋ด…๋‹ˆ๋‹ค. ์ ‘์†์— ์„ฑ๊ณตํ•˜๋ฉด ๋ณ„๋ฌธ์ œ ์—†์ด 80๋ฒˆ ํฌํŠธ๋ฅผ ์ด์šฉํ•ด ์„œ๋น„์Šค๋ฅผ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒ๋‹ˆ๋‹ค.

IP๊ฐ€ ์ง€์†์ ์œผ๋กœ ๋ฐ”๋€” ์ˆ˜ ์žˆ๋‹ค

๊ฐ€์ •์šฉ ์ธํ„ฐ๋„ท์€ DHCP๋กœ ํ• ๋‹น๋ฐ›๊ธฐ์— ์ง€์†์ ์œผ๋กœ IP๊ฐ€ ๋ฐ”๋€” ์ˆ˜ ์žˆ์Œ์„ ์ธ์ง€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. IP๊ฐ€ ๋ฐ”๋€Œ๋ฉด DNS ๋ ˆ์ฝ”๋“œ๋„ ์ƒˆ๋กœ์šด IP์— ์•Œ๋งž๊ฒŒ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋„๋ก Dynamic DNS ๋“ฑ์˜ ์…‹์—…์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

micro SD

micro SD๋ฅผ ์˜›๋‚  ๋ฒ„์ „์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด IO๊ฐ€ ๋‹ค์†Œ ๋Š๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์™•์ด๋ฉด ์ฝ๊ธฐ/์“ฐ๊ธฐ ์†๋„๋ฅผ ๋ณด๊ณ  ๋น ๋ฅธ ๋ชจ๋ธ๋กœ ๊ตฌ๋งค ๋ฐ ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ์ฝ๊ธฐ/์“ฐ๊ธฐ ์†๋„๊ฐ€ ๋Š๋ฆด ๊ฒฝ์šฐ ์‚ฌ์šฉํ•˜์‹œ๋ฉฐ ๋‹ต๋‹ตํ•จ์„ ๋Š๋‚„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์…‹์—…

  • ๋ชจ๋“  ์…‹์—… ์ž‘์—…์€ macOS ์œ„์—์„œ ์ด๋ฃจ์–ด์กŒ์Šต๋‹ˆ๋‹ค. ๋ช…๋ น์–ด ๋˜ํ•œ macOS์˜ ๋ช…๋ น์–ด๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

OS ์„ ํƒ ๋ฐ ๋‚ด๋ ค๋ฐ›๊ธฐ

์˜ค๋ž˜ ๋ฐฉ์น˜๋œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— ์ƒˆ OS๋ฅผ ์˜ฌ๋ ค์ค์‹œ๋‹ค. ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€์—๋Š” NOOBS, Raspbian ๋“ฑ ๋‹ค์–‘ํ•œ ์ด๋ฏธ์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ €๋Š” ์„œ๋ฒ„๋กœ ์‚ฌ์šฉํ•  ๋ชฉ์ ์ด๋ผ Ubuntu Server๋ฅผ ๊ณจ๋ž์Šต๋‹ˆ๋‹ค. ์šฐ๋ถ„ํˆฌ๋Š” ์ต์ˆ™ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ๋„ ์‰ฌ์›Œ ์ œ๊ฐ€ ์ข‹์•„ํ•˜๋Š” OS์ž…๋‹ˆ๋‹ค.

SD Card ํฌ๋งท

๋‚ด๋ ค๋ฐ›๊ธฐ๋ฅผ ๋ˆ„๋ฅด๊ณ , ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ ๊ธฐ๋ณธ ์Šคํ† ๋ฆฌ์ง€๋กœ ์ด์šฉ๋  micro SD์นด๋“œ๋ฅผ ์ปดํ“จํ„ฐ์— ์—ฐ๊ฒฐํ•˜์—ฌ FAT32๋กœ ํฌ๋งทํ•ฉ๋‹ˆ๋‹ค. ๋จผ์ € diskutil list๋ฅผ ์ด์šฉํ•ด Device Node๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. Device Node๋Š” ๋“œ๋ผ์ด๋ธŒ๋ฅผ ๋ฐ€๊ณ  OS ์ด๋ฏธ์ง€ ๊ธฐ๋กํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

$ diskutil list
/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.7 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.7 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            119.4 GB   disk1s1
   2:                APFS Volume Preboot                 43.9 MB    disk1s2
   3:                APFS Volume Recovery                509.8 MB   disk1s3
   4:                APFS Volume VM                      6.4 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *127.9 GB   disk2
   1:               Windows_NTFS                         127.8 GB   disk2s1

์šฉ๋Ÿ‰, ์ด๋ฆ„ ๋“ฑ์œผ๋กœ micro SD์นด๋“œ์˜ Device Node๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ œ micro SD์นด๋“œ๋Š” /dev/disk2์ž…๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  diskutil partitionDisk ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด micro SD์นด๋“œ๋ฅผ FAT32๋กœ ํฌ๋งทํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

diskutil partitionDisk [DeviceNode] [ํŒŒํ‹ฐ์…˜ ๊ฐฏ์ˆ˜] [ํŒŒํ‹ฐ์…˜ ํ…Œ์ด๋ธ” ์ข…๋ฅ˜] [ํŒŒํ‹ฐ์…˜0ํฌ๋งท ํŒŒํ‹ฐ์…˜0์‚ฌ์ด์ฆˆ ํŒŒํ‹ฐ์…˜1ํฌ๋งท ํŒŒํ‹ฐ์…˜1 ์‚ฌ์ด์ฆˆ ...]

์ผ๋‹จ MBR FAT32 ๋‹จ์ผ ํŒŒํ‹ฐ์…˜์œผ๋กœ ํฌ๋งทํ•  ์˜ˆ์ •์ด๋ฏ€๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์‹ค์ˆ˜๋กœ ๋‹ค๋ฅธ ๋””์Šคํฌ๋ฅผ ํฌ๋งทํ•˜์—ฌ ๋˜๋Œ๋ฆด ์ˆ˜ ์—†๋Š” ์‚ฌ๊ณ ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋„๋ก ์‹ ์ค‘ํžˆ ์ž‘์—…ํ•ฉ๋‹ˆ๋‹ค.

$ # ํŒŒํ‹ฐ์…˜ ์‚ฌ์ด์ฆˆ๋ฅผ 0b๋กœ ํ•˜๋ฉด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ์˜์—ญ์„ ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค.
$ diskutil partitionDisk /dev/disk2 1 MBR "MS-DOS FAT32" ROOT 0b
Started partitioning on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s1 as MS-DOS (FAT32) with name ROOT
512 bytes per physical sector
/dev/rdisk2s1: 249674176 sectors in 3901159 FAT32 clusters (32768 bytes/cluster)
bps=512 spc=64 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2048 drv=0x80 bsec=249735168 bspf=30478 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished partitioning on disk2
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *127.9 GB   disk2
   1:                 DOS_FAT_32 ROOT                    127.9 GB   disk2s1

์ด์ „์— ๋‚ด๋ ค๋ฐ›์€ OS ์ด๋ฏธ์ง€ ํŒŒ์ผ์€ -.img.xz ํ˜•์‹์œผ๋กœ ์••์ถ•๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. ์••์ถ•์„ ํ’€์–ด -.img ํ˜•ํƒœ๋กœ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋””์Šคํฌ๋ฅผ ์–ธ๋งˆ์šดํŠธํ•œ ๋‹ค์Œ ๋””์Šคํฌ์— OS ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.

$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
sudo dd bs=1m if=/path/to/image/ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img of=/dev/disk2

ํ˜น์‹œ ์ด ๊ณผ์ •์—์„œ, micro SD์นด๋“œ๊ฐ€ 64GB๋ณด๋‹ค ์ปค FAT32 ํฌ๋งท์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋ฉด ์œˆ๋„ ์ปดํ“จํ„ฐ์—์„œ Win32 Disk Imager๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์ด๋“œ๋Š” ์—ฌ๊ธฐ์— ์žˆ์Šต๋‹ˆ๋‹ค.

์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋˜๋ฉด ์ด๋ฏธ์ง€ ์ค€๋น„๋Š” ๋๋‚ฌ์Šต๋‹ˆ๋‹ค.

OS ์…‹์—…

๊ธฐ๋ก์ด ์™„๋ฃŒ๋˜๋ฉด SD์นด๋“œ์™€ ํ‚ค๋ณด๋“œ, ๋งˆ์šฐ์Šค, ๋ชจ๋‹ˆํ„ฐ, ๋žœ์„  ๋“ฑ์„ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์— ์—ฐ๊ฒฐํ•œ ๋‹ค์Œ ๊ฐ€๋™ํ•ฉ๋‹ˆ๋‹ค. ์ž‘์—… ๋„์ค‘ ์ €์ „์•• ๊ฒฝ๊ณ ๊ฐ€ ๊ณ„์† ๋‚˜ํƒ€๋‚  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ชจ๋“  IO์žฅ์น˜๋ฅผ ์ „๋ถ€ ์‚ฌ์šฉํ•˜์—ฌ ๊ทธ๋Ÿฐ ๊ฒƒ์ด๋ฏ€๋กœ ๋ฌด์‹œํ•ฉ๋‹ˆ๋‹ค.

์ดˆ๊ธฐ ์–ด์นด์šดํŠธ์™€ ํŒจ์Šค์›Œ๋“œ๋Š” ubuntu/ubuntu ์ž…๋‹ˆ๋‹ค. ๊ฐ€์žฅ ๋จผ์ € ํ•  ์ผ์€ ์—ญ์‹œ ๊ณ„์ • ์ด๋ฆ„๊ณผ ํŒจ์Šค์›Œ๋“œ๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. root ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•œ ๋‹ค์Œ ๊ณ„์ • ์ด๋ฆ„ ์ „ํ™˜ ์ž‘์—… ํ›„ ๋ฃจํŠธ ๊ณ„์ •์„ ์ž ๊ฐ€์ค๋‹ˆ๋‹ค.

sudo passwd root
exit
# root ๊ณ„์ •์œผ๋กœ ๋‹ค์‹œ ๋กœ๊ทธ์ธํ•ฉ๋‹ˆ๋‹ค.
usermod -l rajephon -d /home/rajephon -m ubuntu
groupmod -n rajephon ubuntu
passwd -l root
exit

์ƒˆ๋กœ ๋ฐ”๋€ ๊ณ„์ • ์ด๋ฆ„์œผ๋กœ ๋กœ๊ทธ์ธ ํ›„ ํŒจ์Šค์›Œ๋“œ๋ฅผ ๋ฐ”๊ฟ”์ค๋‹ˆ๋‹ค.

passwd rajephon

์ด์ œ ํŒจํ‚ค์ง€๋“ค์„ ์ตœ์‹ ์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๊ณ โ€ฆ

sudo apt update
sudo apt dist-upgrade

์‹œ๊ฐ„๋Œ€๋„ ์šฐ๋ฆฌ๊ฐ€ ์‚ฌ๋Š” ์ง€์—ญ์— ์•Œ๋งž๊ฒŒ ์„ค์ •ํ•ฉ์‹œ๋‹ค.

$ timedatectl set-timezone 'Asia/Seoul'
$ date
Sun Jul  7 21:10:37 KST 2019

์›๊ฒฉ์—์„œ ์ž‘์—…ํ•˜๊ธฐ ํŽธํ•˜๋„๋ก ssh๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

sudo apt install openssh-server openssh-client

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ssh ์ ‘์†์ด ์ž˜ ๋˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ip๋Š” ip a ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์†์‰ฝ๊ฒŒ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

๋„์ปค ์„ค์น˜

๋„์ปค๋Š” ์ง„๋ฆฌ์ž…๋‹ˆ๋‹ค. ์–ธ์ œ ์–ด๋””์—์„œ๋‚˜ ์œ ์ตํ•˜์ฃ . ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์—์„œ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค. ๋„์ปค๋ฅผ ์„ค์น˜ํ•ฉ์‹œ๋‹ค.

# WARNING: Always examine scripts downloaded from the internet before running them locally.
curl -fsSL get.docker.com -o get-docker.sh
sudo bash get-docker.sh

์œ ์ € ๊ณ„์ •์—์„œ๋„ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ทธ๋ฃน ์ถ”๊ฐ€๋„ ์žŠ์ง€ ๋ง™์‹œ๋‹ค.

sudo usermod -aG docker rajephon

DDNS ์…‹์—…

ํ™ˆ ์„œ๋ฒ„์—์„œ ๋™์ ์œผ๋กœ ๋ฐ”๋€Œ๋Š” IP์— ๋Œ€์‘ํ•˜๊ธฐ ์œ„ํ•ด ํ•„์ˆ˜์ ์ธ ์ž‘์—…์ž…๋‹ˆ๋‹ค. google domain, cloudflare, dnszi, dnsever ๋“ฑ ๋Œ€๋ถ€๋ถ„์˜ DNS ์„œ๋น„์Šค๋Š” ๋ชจ๋‘ A ๋ ˆ์ฝ”๋“œ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š” API๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ €๋Š” Cloudflare๋ฅผ ์‚ฌ์šฉ ์ค‘์ด๋ฏ€๋กœ Cloudflare๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

Cloudflare API์— ๋งž์ถฐ ๋™์ž‘ํ•˜๋Š” ํด๋ผ์ด์–ธํŠธ๋กœ ddclient๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
์—ฌ๊ธฐ์„œ ์•ฝ๊ฐ„ ๋ฒˆ๊ฑฐ๋กœ์šด ์ž‘์—…์ด ์žˆ๋Š”๋ฐ, apt ๋ ˆํฌ์— ๋“ฑ๋ก๋˜์–ด์žˆ๋Š” ๊ฐ€์žฅ ์ตœ์‹  ๋ฒ„์ „์€ 3.8.x ์ง€๋งŒ cloudflare์— ๋งž์ถฐ ์‚ฌ์šฉํ•˜๋ ค๋ฉด 3.9.0 ๋ณด๋‹ค ๋†’์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋กœ ์ง์ ‘ ๋‹ค์šด๋กœ๋“œํ•ด์„œ ์„ค์น˜ํ•ด์•ผ ํ•˜์ง€๋งŒ, perl๋กœ ์ž‘์„ฑ๋˜์–ด ๋ณ„๋„์˜ ๋นŒ๋“œ ๊ณผ์ •์ด ์—†์–ด๋„ ๋˜๋ฏ€๋กœ ์–ด๋ ต์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

# ๋™์ž‘์— ํ•„์š”ํ•œ perl ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
sudo apt install libjson-any-perl libdata-validate-ip-perl libio-socket-ssl-perl
# ์ตœ์‹  ddclient๋ฅผ ๋‚ด๋ ค๋ฐ›๊ณ ,
wget https://sourceforge.net/projects/ddclient/files/ddclient/ddclient-3.9.0/ddclient-3.9.0.tar.gz
# ์••์ถ•์„ ํ’€์–ด์ค๋‹ˆ๋‹ค.
tar -xvzf ddclient-3.9.0.tar.gz
cd ddclient-3.9.0/
# /sbin ๋กœ ddclient๋ฅผ ์˜ฎ๊ฒจ์ค๋‹ˆ๋‹ค.
sudo cp ./ddclient /sbin/ddclient
# ์บ์‹œ ๋””๋ ‰ํ† ๋ฆฌ์™€ ๊ธฐ๋ณธ ์„ค์ • ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ , ๊ถŒํ•œ ์กฐ์ ˆ๋„ ํ•ด๋‘ก๋‹ˆ๋‹ค.
sudo mkdir /var/cache/ddclient
sudo chown rajephon /var/cache/ddclient
sudo mkdir /etc/ddclient
sudo touch /etc/ddclient/ddclient.conf;
sudo chown rajephon /etc/ddclient/ddclient.conf

์ด์ œ ddclient ์„ค์ • ํŒŒ์ผ์„ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

# Configuration file for ddclient
#
# /etc/ddclient/ddclient.conf

ssl=yes
use=web
protocol=cloudflare
server=api.cloudflare.com/client/v4
login=[Cloudflare ์ด๋ฉ”์ผ ์ฃผ์†Œ]
password=[Cloudflare APIKEY]
zone=domain.com
domain.com, my.domain.com

API Key๋Š” Cloudflare์˜ My Profile ํ•ญ๋ชฉ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. zone์—๋Š” ๋‚ด ๋„๋ฉ”์ธ ์ด๋ฆ„์„ ์ ๊ณ , ๋งˆ๋กœ ๋ฐ‘ ์ค„์— A ๋ ˆ์ฝ”๋“œ IP๋ฅผ ๋ณ€๊ฒฝํ•  ์„œ๋ธŒ ๋„๋ฉ”์ธ๋“ค์„ ์ฝค๋งˆ(,)๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ๋‚˜์—ดํ•ฉ๋‹ˆ๋‹ค.

์ด์ œ ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ด…์‹œ๋‹ค.

$ sudo /sbin/ddclient --force
[sudo] password for rajephon:
SUCCESS:  domain.com -- Updated Successfully to 111.222.333.444
SUCCESS:  my.domain.com -- Updated Successfully to 111.222.333.444

cloudflare console์— ๋“ค์–ด๊ฐ€ ๋ณด๋ฉด IP ์ฃผ์†Œ๊ฐ€ ์—…๋ฐ์ดํŠธ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ •์ƒ ๋™์ž‘๋„ ํ™•์ธํ–ˆ์œผ๋‹ˆ ์ด์ œ ์ฃผ๊ธฐ์ ์œผ๋กœ IP ๋ณ€๊ฒฝ ํ™•์ธ ๋ฐ ์—…๋ฐ์ดํŠธ๋ฅผ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“ค์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. ddclient๋ฅผ ์‹œ์ž‘ ํ”„๋กœ๊ทธ๋žจ ๋ฆฌ์ŠคํŠธ์— ๊ฑธ์–ด๋‘๊ณ , ddclient์˜ daemon ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•, cron์— ๋“ฑ๋กํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ €๋Š” cron์œผ๋กœ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
sudo crontab -e ๋กœ ํฌ๋ก ํƒญ ํŽธ์ง‘๋ชจ๋“œ๋กœ ๋“ค์–ด๊ฐ€ ์•„๋ž˜์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

# 2๋ถ„๋งˆ๋‹ค IP ์—…๋ฐ์ดํŠธ ํ™•์ธ ๋ฐ ๊ฐฑ์‹ 
*/2 * * * * /sbin/ddclient

์ข€ ๋” ๋งŽ์€ ๋กœ๊ทธ๋ฅผ ๋‚จ๊ธฐ๊ณ  ์‹ถ์„ ๊ฒฝ์šฐ, -noquiet -query -verbose -debug ๋“ฑ์˜ ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•ด์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • {no}quiet : print {no} messages for unnecessary updates (default: noquiet).
  • {no}query : print {no} ip addresses and exit.
  • {no}verbose : print {no} verbose information (default: noverbose).
  • {no}debug : print {no} debugging information (default: nodebug).

cron์ด ์ž˜ ๋Œ๊ณ  ์žˆ๋Š” ์ง€ ๊ถ๊ธˆํ•˜๋ฉด, syslog๋ฅผ ์ด์šฉํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ tail /var/log/syslog | grep CRON
Jul 12 19:40:01 ubuntu CRON[13164]: (root) CMD (/sbin/ddclient)
Jul 12 19:42:01 ubuntu CRON[13181]: (root) CMD (/sbin/ddclient)

์›น ์„œ๋ฒ„ ๋„์šฐ๊ธฐ

์ด์ œ ๊ธฐ๋ณธ ์ค€๋น„๋Š” ๋๋‚ฌ์œผ๋‹ˆ ์„œ๋ฒ„๋ฅผ ์˜ฌ๋ ค๋ด…์‹œ๋‹ค. ์•ž์„œ ์„ค์น˜ํ•œ ๋„์ปค๋ฅผ ํ™œ์šฉํ•ฉ๋‹ˆ๋‹ค.
๋„์ปค ์ด๋ฏธ์ง€๋Š” ๋ฏธ๋ฆฌ ์ค€๋น„ํ•œ ์›น ์„œ๋น„์Šค๋ฅผ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด๋กœ ๊ฐ€์ ธ์™€ ๋นŒ๋“œํ–ˆ์Šต๋‹ˆ๋‹ค.

docker run --name my-home-page -p 443:443 my-home-image:1.0 -d

์ž ๊ทธ๋Ÿผ ์ด์ œ ์›น ๋ธŒ๋ผ์šฐ์ €๋กœ ์•ž์„œ DDNS๋กœ ์—ฐ๊ฒฐํ•œ ๋„๋ฉ”์ธ์— ์ ‘์†ํ•˜๋ฉด,

01

์งœ์ž”! ์ •์ƒ์ ์œผ๋กœ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด ์›น ์„œ๋ฒ„๋กœ ์ ‘์†๋ฉ๋‹ˆ๋‹ค.
๋ชจ๋“  ์ž‘์—…์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋งˆ๋ฌด๋ฆฌ

์‚ฌ์‹ค, DDNS ์…‹์—…์„ ํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ ๋ง๊ณ ๋Š” ์ผ๋ฐ˜์ ์ธ ์šฐ๋ถ„ํˆฌ ์„œ๋ฒ„์™€ ๋‹ค๋ฅผ ๊ฒŒ ์—†์Šต๋‹ˆ๋‹ค. ๋” ์ด์ƒ ๋ˆ์„ ๋‚ด๊ณ  ์‚ฌ์šฉํ•˜๋Š” ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค๊ฐ€ ์•„๋‹ˆ๋ฏ€๋กœ ๋ณ„๋„์˜ ๋ฐฉํ™”๋ฒฝ์ด๋‚˜ ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ ๋Œ€์‘ ์‹œ์Šคํ…œ์ด ์—†๋Š” ์ ์ด ์กฐ๊ธˆ ์•„์‰ฝ์ง€๋งŒ ํ•˜๋“œํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ๊ฒƒ์ด ์•„๋‹ˆ๋ฏ€๋กœ ๋ฌธ์ œ๊ฐ€ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ž‘์—…ํ•˜๋ฉด์„œ ์‹ค์ˆ˜ํ–ˆ๋˜ ์ ์€ ์œ„์—์„œ ์„ค๋ช…์€ ์•ˆ ํ–ˆ์ง€๋งŒ ์ฒ˜์Œ์— ์›น ์„œ๋ฒ„ ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๋งŒ๋“ค ๋•Œ ๋ผ์ฆˆ๋ฒ ๋ฆฌํŒŒ์ด์˜ ์•„ํ‚คํ…์ฒ˜๊ฐ€ arm64๋กœ ๋‹ค๋ฅด๋‹ค๋Š” ๊ฒƒ์„ ๋†“์ณค์Šต๋‹ˆ๋‹ค. macOS์—์„œ ๋‹ค๋ฅธ ์•„ํ‚คํ…์ฒ˜๋กœ ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๊ตฝ๋Š” ๊ฒƒ์€ ํ˜„์žฌ Edge์—์„œ๋งŒ ๋˜๋Š”๋ฐ, Edge๋Š” Stable์ด ์•„๋‹ˆ๋ผ ๋น ๋ฅด๊ฒŒ ํฌ๊ธฐํ•˜๊ณ  ์ผ๋‹จ์€ ํ™ˆ ์„œ๋ฒ„ ๋กœ์ปฌ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๊ตฌ์› ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ