OPNsense Forum

English Forums => General Discussion => Topic started by: Sarpendon on October 19, 2022, 06:56:34 PM

Title: Dual WAN limiting local IP to use one WAN Gateway
Post by: Sarpendon on October 19, 2022, 06:56:34 PM
Hello and I'm sorry to bother here with my lack of competence, but it's my first time now trying around with OPNsense and so far everything works fine.

I just encountered an Problem I don't know how to solve.

I use OPNsense with 2 WAN Interfaces from 2 different ISP's in load balancing. The Network speed is awesome and really happy with the result. One of the WAN's has a static IP and for some personal projects I would need to bind certain Local Devices to only use the Gateway with the static IP. I coudn't figure out how to limit certain Local Devices to only use a designated Gateway. Before I switched to OPNsene I been using an Asus MerlinWRT router and there was the Routing Rules Option with Dual WAN to limit certain local IP's to one of the WAN's.

Is there a way to do the same in OPNsense ?
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: tiermutter on October 19, 2022, 08:19:50 PM
Policy based routing is the way to go.
Create a pass any rule for the internal interface/ LAN, select the devices that should route to the specific GW as source and select the gateway at the end of the rule-config-screen. Place this rule above "default allow" rule.
To select multiple devices following this route, create an alias containing the IPs or (preferred) MACs of the devices. Use this alias as source in the FW rule.
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: Sarpendon on October 19, 2022, 08:31:29 PM
Thank you I'll try it out now :)
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: Sarpendon on October 19, 2022, 08:52:05 PM
Quote from: tiermutter on October 19, 2022, 08:19:50 PM
Policy based routing is the way to go.
Create a pass any rule for the internal interface/ LAN, select the devices that should route to the specific GW as source and select the gateway at the end of the rule-config-screen. Place this rule above "default allow" rule.
To select multiple devices following this route, create an alias containing the IPs or (preferred) MACs of the devices. Use this alias as source in the FW rule.

Ok so I tired it out and added the Alias with the MAC's to the Rule and set up the rule to pass any trafic to a specific GW. But still the Devices don't use the right GW.
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: tiermutter on October 19, 2022, 10:03:22 PM
Looks good so far. Is it possible that the traffic is ipv6, causing your v4 rules to not be taken into account?
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: Sarpendon on October 19, 2022, 10:10:56 PM
I am mostly sure the trafic is not ipv6 but yeah still don't know what the problem is.  :-\
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: tiermutter on October 20, 2022, 06:33:02 AM
How did you check where the traffic goes out?
For those routing purposes (I am only routing v4 to specefic GW) I created a v6 block rule, blocking v6 for the alias to ensure v6 will never be used an routed to other GW.

This works for me for multiple devices (one ruleset is only used temporarily):
(https://forum.opnsense.org/index.php?action=dlattach;topic=30742.0;attach=24002)
Title: Re: Dual WAN limiting local IP to use one WAN Gateway
Post by: Sarpendon on October 20, 2022, 08:23:33 AM
Thank you but it was my own fault, my dumb ass set up the alias wrong and now it works fine. My apologies for the troubles. Have a nice day.