ssh로 접속 후 wireguard 설치
repository가 등록되어 있지 않아서 아래와 같이 추가하여 설치하자
sudo add-apt-repository ppa:wireguard/wireguard
sudo apt install wireguard
서버 공개키 개인키 생성
sudo mkdir -p /etc/wireguard/server; wg genkey | sudo tee /etc/wireguard/server/server.key | wg pubkey | sudo tee /etc/wireguard/server/server.key.pub
서버 공개키 출력
공개키 개인키 재확인
cat /etc/wireguard/server/server.key.pub
cat /etc/wireguard/server/server.key
서버 설정파일 제작
sudo nano /etc/wireguard/wg0.conf
[Interface]
Address = 192.168.2.1/32
PrivateKey = Server_private_key
ListenPort = 1194
[Peer]
PublicKey = Client_1_public_key
AllowedIPs = 192.168.2.2/32
- Address: VPN 접속시 서버 IP 주소
- PrivateKey: 서버의 개인키
- ListenPort: 사용 포트 (방화벽 에서 열어줘야함, 공유기 사용시 포트포워딩 필요)
- PublicKey: 접속에 사용하는 client(PC나 모바일폰)의 PublicKey
- AllowedIPs: client 할당 IP
모바일용 QR 코드 제작을 위한 설정
qrencode 설치
sudo apt install qrencode
QR코드용 공개키 개인키 생성 후 확인
sudo mkdir -p /etc/wireguard/clients; wg genkey | sudo tee /etc/wireguard/clients/mobile.key | wg pubkey | sudo tee /etc/wireguard/clients/mobile.key.pub
cat /etc/wireguard/clients/mobile.key
위쪽 박스: 공개키
아래쪽 박스: 개인키
QR코드용 설정파일 제작
sudo nano /etc/wireguard/clients/mobile.conf
[Interface]
PrivateKey = Mobile_Private_key
Address = 192.168.2.3/24
DNS = 1.1.1.1, 1.0.0.1
[Peer]
PublicKey = YOUR_SERVER_PUBLIC_KEY
AllowedIPs = 0.0.0.0/0
Endpoint = YOUR_SERVER_WAN_IP:1194
- Endpoint: 서버IP (또는 DDNS 주소 사용 가능)
서버 설정파일에 Peer 추가
sudo nano /etc/wireguard/wg0.conf
[Interface]
Address = 192.168.2.1/32
PrivateKey = Server_private_key
ListenPort = 1194
[Peer]
PublicKey = Client_1_public_key
AllowedIPs = 192.168.2.2/32
[Peer]
PublicKey = Mobile_public_key
AllowedIPs = 192.168.2.3/32
QR 코드 생성
qrencode -t ansiutf8 < /etc/wireguard/clients/mobile.conf
Wireguard 실행
wg-quick up wg0
이제 생성된 QR 코드를 소중하게 잘 보관하고 wireguard android 앱에서 QR스캔하면 접속 가능!
Wireguard 가 실행되어 있을 경우에는 아래와 같이 재시작 필요
wg-quick down wg0 && wg-quick up wg0
시스템 재시작시 자동 실행 등록
sudo systemctl enable wg-quick@wg0
Synology NAS의 경우 제어판-작업스케줄러에 시작시 아래와 같이 실행하도록 설정
sleep 60
wg-quick up wg0
sleep 5
wg-quick down wg0
sleep 5
wg-quick up wg0
윈도우에서는 아래와 같이 설정되어야 함 참조하여 윈도우 client 셋팅하고 서버 설정파일에 키를 잘 넣어주자.
이상 끝
참조할만한 링크
https://golb.hplar.ch/2019/07/wireguard-windows.html
Setting up WireGuard on Windows
A few months ago, I wrote a tutorial on how to install WireGuard, a simple, fast, and modern VPN, on Linux and open a VPN connection from an Android device. Because I work most time on Windows I was also especially interested in connecting my computer to a
golb.hplar.ch
https://serversideup.net/generating-wireguard-qr-codes-for-fast-mobile-deployments/
Generating Wireguard QR codes for fast mobile deployments - Server Side Up
Supporting mobile devices with Wireguard VPN can be dramatically easier by using a QR code. Learn how to generate a Wireguard QR code for your clients in just a few minutes.
serversideup.net
https://serversideup.net/how-to-configure-a-wireguard-ios-client/
How to configure a Wireguard iOS client - Server Side Up
This is a coniutation of my free “mini-course” called Gain Flexibility & Increase Privacy with Wireguard VPN. Start there if you are new to Wireguard. What you’ll achieve We will have our iPhone client connecting to our Wireguard VPN server This is w
serversideup.net
https://serversideup.net/how-to-configure-a-wireguard-android-vpn-client/
How to configure a Wireguard Android VPN Client - Server Side Up
Learn how to easily configure a Wireguard Android client. Using QR codes, I'll show you how you to easily configure a remote device in minutes.
serversideup.net
https://ziwon.github.io/post/wireguard/
WireGuard 설치 및 방화벽 설정 | ziwon.github.io
WireGuard 소개 WireGuard는 임베디드 인터페이스와 슈퍼 컴퓨터를 위한 범용 VPN로, 최첨단 암호화 기술을 사용하며 단순하고 빠르고 현대적인 VPN이다. IPsec보다 더 간단하며 더 빠르고, OpenVPN보다 성�
ziwon.github.io
https://www.wireguard.com/quickstart/
Quick Start - WireGuard
Quick Start You'll first want to make sure you have a decent grasp of the conceptual overview, and then install WireGuard. After that, read onwards here. Side by Side Video Before explaining the actual comands in detail, it may be extremely instructive to
www.wireguard.com
사족. 서버와 라우터의 방화벽 설정을 잘 해야 한다. 해당 포트들 오픈이 안되있으면 연결이 안됨
'서버와 홈디바이스 > NAS, VPN, 클라우드' 카테고리의 다른 글
Proxmox UPS 설정 가이드 (1) | 2023.03.22 |
---|---|
시놀로지 duckdns dns 인증서 설정 - acme (0) | 2023.03.22 |
Proxmox 7.0 컨테이너에서 plex hw 트랜스코딩 사용 (0) | 2021.08.16 |
Android ADB 연결 후 vi / nano 에디터 사용 (0) | 2020.08.13 |
WireGurad 설치 - RT2600ac 시놀로지 라우터 (0) | 2020.07.23 |