WireGuard 기본 안내
WireGuard
WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography.
WireGuard는 최첨단 암호화 기술을 활용한 매우 단순하고 빠르며 현대적인 VPN입니다.
서버와 클라이언트 모두 네트워크 인터페이스를 생성하며 이를 위한 설정 파일이 있습니다. wg0
라는 네트워크 인터페이스를 설정하려면 /etc/wireguard/wg0.conf
파일을 생성하여 설정하면 됩니다.
Cryptokey Routing Table
서버의 설정파일 예시는 아래와 같습니다.
/etc/wireguard/wg0.conf
[Interface]
PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
ListenPort = 51820
# Peer1
[Peer]
PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
AllowedIPs = 10.192.122.3/32, 10.192.124.1/24
# Peer2
[Peer]
PublicKey = TrMvSoP4jYQlY6RIzBgbssQqY3vxI2Pi+y71lOWWXX0=
AllowedIPs = 10.192.122.4/32, 192.168.0.0/16
# Peer3
[Peer]
PublicKey = gN65BkIKy1eCE9pP1wdc8ROUtkHLF2PfAqYdyYBz6EA=
AllowedIPs = 10.10.10.230/32
패킷이 Peer
-> Interface
방향으로 전달되면 PrivateKey
로 패킷을 복호화합니다. 그리고 source IP가 해당 피어의 AllowedIPs
에 포함되어 있다면 네트워크 인터페이스로 보내고 아니면 버립니다. 예를 들어 Peer1이 패킷을 보냈을때, source IP가 10.192.122.3
이었다면 이 패킷을 허용하고 아니면 삭제합니다.
패킷이 Interface
-> Peer
방향으로 전달되면 destination IP를 확인하여 피어 목록에서 해당 IP를 AllowedIPs
로 가진 피어를 찾습니다. 피어를 찾았다면 패킷을 해당 피어의 PublicKey
로 암호화하여 해당 피어의 가장 최근 엔드포인트로 보냅니다. 예를 들어 destination IP가 10.10.10.230
이었다면 Peer3에게 패킷을 보냅니다.