I'm trying to configure a Wireguard client currently set to route all traffic through Wireguard to only route one network interface through Wireguard.
Ex: The Client has both wlan0 and eth0 interfaces and I would like to route traffic from eth0 to wireguard, having wlan0 (and all of its traffic) accessible to the internet and not routed.
I do not want to use the IP address as a way to adjust the traffic as the client (which is a SFF PC) changes locations and networks and would require re-configuration given the newly assigned IP address.
I use docker containers on the client that are configured to use the different network interfaces for different tasks and would like the traffic for the interfaces split between the eth0 and wlan0 interfaces.
Ex: I have a web server with a container control panel which is accessible by the IP address/ port combination exposed by the eth0 interface (192.168.0.**:3100).
I use this in combination with Wireguard while I'm remote to control and update the web server for maintenance (through the ip address assigned by the client through Wireguard (10.68.9.*:3100).
The same server uses the wlan0 interface to serve the actual site to the internet -- given the latency of the eth0 interface through Wireguard would be bad for traffic to and from the site.
Both server and control panel communicate through the local network of the computer.
Everytime Wireguard is enabled for the client, wlan0 is knocked out.
I've tried writing PostUp/Down rules that explicitly route traffic from eth0 to Wireguard and leave wlan0 alone, so that I can access the control panel of the application while still having it accessible over wlan0, but they didn't seem to work.
Here were my rules for postUp -- same as postDown aside from the -I / -D
iptables -t nat -I POSTROUTING 1 -s <ip4-address> -o eth0 -j MASQUERADE;
ip6tables -t nat -I POSTROUTING 1 -s <ip6-address> -o eth0 -j MASQUERADE;
iptables -I INPUT 1 -i wg0 -j ACCEPT;
iptables -I FORWARD 1 -i eth0 -o wg0 -j ACCEPT;
iptables -I FORWARD 1 -i wg0 -o eth0 -j ACCEPT;
iptables -I INPUT 1 -i eth0 -p udp --dport 51820 -j ACCEPT
Here's the output of ip route on my current network
default via 192.168.0.1 dev eth0 proto dhcp metric 100
default via 192.168.0.1 dev wlan0 proto dhcp metric 600
169.254.0.0/16 dev eth0 scope link metric 1000
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.192 metric 100
192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.105 metric 600
Basically: All eth0 traffic through Wireguard, all wlan0 traffic not.