Half-Working Routed Docker Subnet WireGuard: Docker Subnet 192.168.50.0
In this article, we will discuss a common issue that arises when trying to route traffic from a Docker subnet to a WireGuard interface. Specifically, we will focus on the Docker subnet with the IP address range of 192.168.50.0. We will cover the key concepts related to this issue, provide detailed context, and offer a solution.
Background
WireGuard is a simple, fast, and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN.
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.
The Issue
When trying to route traffic from a Docker subnet to a WireGuard interface, you might encounter an issue where the traffic is not being routed as expected. This is because the Docker subnet is not automatically routed to the WireGuard interface.
Solution
To solve this issue, you need to manually configure the routing table on the client side. Here are the steps to follow:
- Create a WireGuard interface on the client side.
- Add the necessary peers to the WireGuard interface.
- Configure the WireGuard interface to use the Docker subnet as the allowed IPs.
- Add a route to the routing table on the client side to route traffic destined for the Docker subnet through the WireGuard interface.
Example
Here is an example of how to configure the client side to route traffic destined for the Docker subnet (192.168.50.0) through the WireGuard interface:
# Add a new WireGuard interface
sudo wg-quick up wg0
# Add the necessary peers to the WireGuard interface
wg set wg0 peer allowed-ips 192.168.50.0/24
# Configure the WireGuard interface to use the Docker subnet as the allowed IPs
sudo ip addr add 192.168.50.1/24 dev wg0
# Add a route to the routing table on the client side to route traffic destined for the Docker subnet through the WireGuard interface
sudo ip route add 192.168.50.0/24 dev wg0 References
This article covers the issue of routing traffic from a Docker subnet to a WireGuard interface, specifically the Docker subnet with the IP address range of 192.168.50.0. We have discussed the background, the issue, the solution, and provided an example. We have also included references for further reading.