Hi everyone,
I have a setup with two VPN containers (DE-VPN and CH-VPN), each using a tun0 interface internally. On the host, these containers are represented by the interfaces veth900i0 and veth901i0.
My goal is to route specific traffic (domain based) through the respective VPNs. Because I don't want to care about the ip-lists/routing tables manually, I wan to use my reverse Proxy and dnsmasq for keeping the server ips up to date. Here’s what I’ve done so far:
Does anyone have any idea what might be wrong or what I may have missed?
Thanks a lot!
I have a setup with two VPN containers (DE-VPN and CH-VPN), each using a tun0 interface internally. On the host, these containers are represented by the interfaces veth900i0 and veth901i0.
My goal is to route specific traffic (domain based) through the respective VPNs. Because I don't want to care about the ip-lists/routing tables manually, I wan to use my reverse Proxy and dnsmasq for keeping the server ips up to date. Here’s what I’ve done so far:
- Created routing tables:
- de-vpn with ID 190
- ch-vpn with ID 191
- Added mangle rules to mark the traffic:
- Traffic for DE-VPN:
iptables -t mangle -A PREROUTING -m set --match-set de-vpnset dst -j MARK --set-mark 0x1 - Traffic for CH-VPN:
iptables -t mangle -A PREROUTING -m set --match-set ch-vpnset dst -j MARK --set-mark 0x2
- Traffic for DE-VPN:
- Created routing rules to route the marked traffic through the respective VPNs:
ip rule add fwmark 0x1 table 190ip route add default via 192.168.187.190 dev veth900i0 table 190ip rule add fwmark 0x2 table 191ip route add default via 192.168.187.191 dev veth901i0 table 191
- Configured NAT rules to NAT the traffic through the VPNs:
iptables -t nat -A POSTROUTING -o veth900i0 -j MASQUERADE (for DE-VPN)iptables -t nat -A POSTROUTING -o veth901i0 -j MASQUERADE (for CH-VPN)
Does anyone have any idea what might be wrong or what I may have missed?
Thanks a lot!