1
23.7 Legacy Series / MultiWAN: Force traffic from firewall itself to specific gateway
« on: December 08, 2023, 01:42:10 am »
Hi guys.
I am using opnsense 23.7.9 with two ISPs and two WAN interfaces. I want to use WAN1 to update my dyndns address, never WAN2.
So that's what I did to achieve that:
ddclient is using api.ipify.org to determine my IP, and uses the default gateway for that (which is the wrong one, WAN2).
I created an alias for api.ipify.org, created a floating fw rule, source "this firewall", destination alias, ipv4, any port, no specific interface selected, and then set the gateway to WAN1.
As soon as I enable this rule, curl -s https://api.ipify.org fails and never returns an address. If I disable the rule, it returns the IP from the wrong WAN interface.
As a sanity check I created a LAN rule, outgoing, from any host in my LAN, destination again the alias. If I run Invoke-RestMethod -Uri 'https://api.ipify.org?format=json' on a windows machine in my LAN, it uses the correct gateway and returns the correct address. As soon as I disable the run, it returns the wrong one.
So in my LAN case, it works as expected.
How can I make this work for traffic from the opnsense itself? For testing I even set the destination to any, routing all the traffic from opnsense over that specific gateway. As soon as I enabled that, even pings to 8.8.8.8 timed out.
What did I do wrong here?
I am using opnsense 23.7.9 with two ISPs and two WAN interfaces. I want to use WAN1 to update my dyndns address, never WAN2.
So that's what I did to achieve that:
ddclient is using api.ipify.org to determine my IP, and uses the default gateway for that (which is the wrong one, WAN2).
I created an alias for api.ipify.org, created a floating fw rule, source "this firewall", destination alias, ipv4, any port, no specific interface selected, and then set the gateway to WAN1.
As soon as I enable this rule, curl -s https://api.ipify.org fails and never returns an address. If I disable the rule, it returns the IP from the wrong WAN interface.
As a sanity check I created a LAN rule, outgoing, from any host in my LAN, destination again the alias. If I run Invoke-RestMethod -Uri 'https://api.ipify.org?format=json' on a windows machine in my LAN, it uses the correct gateway and returns the correct address. As soon as I disable the run, it returns the wrong one.
So in my LAN case, it works as expected.
How can I make this work for traffic from the opnsense itself? For testing I even set the destination to any, routing all the traffic from opnsense over that specific gateway. As soon as I enabled that, even pings to 8.8.8.8 timed out.
What did I do wrong here?

