OPNsense Forum

English Forums => General Discussion => Topic started by: NFKhalaychidi on December 08, 2021, 11:54:18 AM

Title: Different gateways for different computers
Post by: NFKhalaychidi on December 08, 2021, 11:54:18 AM
I have a device with OPNSense with 3 ports, one is for LAN, other two are for WAN1 and WAN2 from different providers
I have to do the following:
(1) All clients are using WAN1 to go to the Internet
(2) Some IP's have to use WAN2 instead
By default all clients are using WAN1 and (1) is working
How can I configure OPNsense to make (2) working?
I tried to configure the following firewall rule:

Interface: LAN
Direction: in
Protocol: any
Source: Single host 10.0.0.7/16
Destination: any
Gateway: WAN2_Gateway


When I enable this rule ALL computers are using WAN2, and nobody uses WAN1.
Any suggestions to fix it?
Title: Re: Different gateways for different computers
Post by: chemlud on December 08, 2021, 01:19:40 PM
10.0.0.7/32

maybe?
Title: Re: Different gateways for different computers
Post by: autone on December 09, 2021, 04:41:54 AM
Create a firewall ALIAS. Put those IPs for WAN2 in the ALIAS and use a firewall rule to forward that ALIAS to WAN2.
Title: Re: Different gateways for different computers
Post by: NFKhalaychidi on December 09, 2021, 08:46:41 AM
Quote from: chemlud on December 08, 2021, 01:19:40 PM
10.0.0.7/32

maybe?

Yes. So simple. I thought "10.0.0.0/16" is subnet, and "10.0.0.7/16" is single host, but OPNsense doesn't think so
Title: Re: Different gateways for different computers
Post by: NFKhalaychidi on December 09, 2021, 08:54:15 AM
Quote from: autone on December 09, 2021, 04:41:54 AM
Create a firewall ALIAS. Put those IPs for WAN2 in the ALIAS and use a firewall rule to forward that ALIAS to WAN2.
It works too! Thanks for this way
Title: Re: Different gateways for different computers
Post by: chemlud on December 09, 2021, 09:41:24 AM
Quote from: NFKhalaychidi on December 09, 2021, 08:46:41 AM
Quote from: chemlud on December 08, 2021, 01:19:40 PM
10.0.0.7/32

maybe?

Yes. So simple. I thought "10.0.0.0/16" is subnet, and "10.0.0.7/16" is single host, but OPNsense doesn't think so

That has nothing to do with opnsense, but with network subnet masks in general ;-)

https://en.wikipedia.org/wiki/Subnet_mask