C.W.K.
Stream
Lesson 04 of 12 · published

WireGuard 셋업

~18 min · wireguard, wg-quick, keys, config

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

전체 셋업, end to end

최소지만 완전한 WireGuard 셋업 걸어가기 — 서버 한 대 (항상 도달 가능, public IP 가짐), 클라이언트 한 대 (네 노트북). 같은 패턴이 [Peer] block 더 추가해서 많은 클라이언트로 확장.

Code

Step 1 — 각 장치에서 키 생성·bash
# On the server
wg genkey | tee server-private.key | wg pubkey > server-public.key

# On the client (laptop)
wg genkey | tee client-private.key | wg pubkey > client-public.key

# Each side keeps its private key secret, shares only the public key
cat server-public.key
cat client-public.key
Step 2 — 서버 config /etc/wireguard/wg0.conf·ini
[Interface]
PrivateKey = <server-private-key>
Address = 10.0.0.1/24
ListenPort = 51820
# If you want to NAT client traffic out the server's main interface (full-tunnel VPN):
PostUp   = iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE

[Peer]
PublicKey = <client-public-key>
AllowedIPs = 10.0.0.2/32
Step 3 — 클라이언트 config /etc/wireguard/wg0.conf·ini
[Interface]
PrivateKey = <client-private-key>
Address = 10.0.0.2/24
DNS = 1.1.1.1

[Peer]
PublicKey = <server-public-key>
Endpoint = your-server.example.com:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
Step 4 — 올리고 검증·bash
# On both sides
sudo wg-quick up wg0

# Status
sudo wg show

# Stop
sudo wg-quick down wg0

# Auto-start on boot (Linux)
sudo systemctl enable wg-quick@wg0

# Test the tunnel — from client, ping the server's tunnel IP
ping 10.0.0.1

# Verify your public IP changed (full-tunnel mode)
curl -s ifconfig.me   # should show server's public IP, not your local one

External links

Exercise

Public 도달 가능한 Linux 서버 (DO droplet, port forward 의 집 서버) 있으면 동작하는 server+client 페어 위해 4 step 따라해. 클라이언트에서 ping 10.0.0.1 으로 검증. 그런 서버 없으면 — 다음 레슨 (Tailscale) 이 같은 사용 사례를 그런 거 필요 없이 다뤄.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.