WAN WAN : : : DSL-Provider : DSL-Provider : : .---+---. .--+--. WAN | DSL | | DSL | WAN2 '---+---' '--+--' | | | Stat public IP |Public IP +------| OPNsense |------+ | | LAN | | LAN | | .-----+------. | LAN-Switch | '-----+------' | ...-----+-----... (Clients/Servers) 10.1.1.0/24 und 192.168.4.0/24
Das WireGuard Paket kommt über das richtige WAN Interface (Tier 2 mit statischen IPs) rein und geht aber über das falsche (Tier 1) raus.Mir fehlt aber gerade die Phantasie, wie ich für den Wireguard Serice den Traffic über Tier 2 outbound erzwinge?
Wireguard uses the kernel routing table for where to route traffic which is always going to be the default route unless you have other more specific routes.
The core limitation here is that wg doesn't have a concept of connections, and thus won't try to send replies from the same ip where incoming packets arrived.
Either a single wg interface on the server + SNAT, or one wg interface per wan interface + DNAT or network namespaces.
[12:22:56] Just to verify: I cannot even bind wg to listen on a specific interface/ip only, right?[12:23:39] No, unfortunately not. That may change at some point, though.
[12:19:25] Could you do some policy based stuff for this based on wireguards port perhaps?[12:21:05] Unless you want to stick every wan interface into its own network ns (each with its own wg tunnel), you're gonna have to involve netfilter in this somehow.[12:21:05] in fact, thats over complicating it...[12:21:27] Just set DNAT rule for wireguards port surely?[12:22:04] And there are numerous ways of pulling that off, sure, but NAT is by far the simplest to set up, because it leaves most of the work to the conntracking machinery.[12:23:24] Either a DNAT rule that maps traffic to different wg interfaces depending on the input interface, or, if you're hell-bent on using only a single wg interface, SNAT + some hackery.