OPNsense Forum

English Forums => Virtual private networks => Topic started by: liceo on October 25, 2020, 02:08:40 pm

Title: OpenVPN on Multi-WAN Environment
Post by: liceo on October 25, 2020, 02:08:40 pm
Hi there!

I replaced pfsense with opensense few weeks ago, and i really like it! In relation to a multi-WAN environment, it behaves different than pfsense as far i understood. To make use of a gateway group and it's redundancy options, there is a need to create firewall rules which routes the traffic to the gateway group. This works fine so far e.g.  any LAN interface.

But what i don't get to work is my OpenVPN setup with a dual/multi-WAN configuration, the result is:


I also searched the forum and read through the official documentation, without success. I also tried to add a rule for the OpenVPN Interface, but this was not working.

Any ideas how to solve this problem?

Thanks in advance!

Title: Re: OpenVPN on Multi-WAN Environment
Post by: george09 on November 17, 2020, 04:55:21 pm
Hi,
i want to do the same, do you found a solution?

regards

[EDIT] found you're german thread: https://forum.opnsense.org/index.php?topic=19804.msg92059#msg92059 (https://forum.opnsense.org/index.php?topic=19804.msg92059#msg92059) :)
Title: Re: OpenVPN on Multi-WAN Environment
Post by: liceo on November 17, 2020, 05:48:17 pm
Well, yes i have posted twice ;-). The solution with port forwarding OpenVPN traffic to localhost, was not properly working => It was only working over one WAN interface, but i don't know the root cause yet. It's probably related to the HA setup i have in place.

Now i set up two OpenVPN servers, one for each WAN interface. You can copy the first Server you have configured, you only need to change the interface the server is listening to the second WAN and assign another IP tunnel network IP range.
In case you have a high availability setup, take the CARP VIP as your WAN address in the OpenVPN config.

Example Configuration:

Settings OpenVPN Server #1:

Settings OpenVPN Server #2:

This seems to work stable.
Title: Re: OpenVPN on Multi-WAN Environment
Post by: Gauss23 on November 17, 2020, 05:56:13 pm
Firewall: Settings: Advanced
Do you have enabled: "Disable reply-to on WAN rules" ?
Usually pakets should leave the same way they entered.
Title: Re: OpenVPN on Multi-WAN Environment
Post by: liceo on November 17, 2020, 06:07:19 pm
Quote
Do you have enabled: "Disable reply-to on WAN rules" ?
No, the option its unchecked (not disabled)
Title: Re: OpenVPN on Multi-WAN Environment
Post by: mimugmail on November 17, 2020, 06:41:01 pm
Check in Interfaces : WAN if wan interfaces have an upstream gateway
Title: Re: OpenVPN on Multi-WAN Environment
Post by: liceo on November 17, 2020, 07:16:43 pm
Quote
WAN if wan interfaces have an upstream gateway
Yes, both WAN interfaces has an upstream gateway configured.
Title: Re: OpenVPN on Multi-WAN Environment
Post by: mimugmail on November 17, 2020, 08:03:43 pm
Oh,you have carp, then maybe bind the instance to LAN VIP and do Port forward there
Title: Re: OpenVPN on Multi-WAN Environment
Post by: liceo on November 17, 2020, 08:13:41 pm
Yes, i also tried this, same results... but anyway, the setup with the two OpnVPN server instances works well at the moment.
Title: Re: OpenVPN on Multi-WAN Environment
Post by: _Alchemist_ on October 20, 2021, 08:41:00 pm
I am using this with my dual WAN setup (1x cable, 1x dsl):

Firewall --> NAT --> Port Forward
--> Add (+)

- Interface                                WAN1
- Protocol                                 UDP
- Destination                            WAN1 address
- Destination port range           from:                to:
                                                OpenVPN        OpenVPN
-  Redirect target IP                 Single Host or Network
                                                127.0.0.1
- NAT reflection                        Use system default
- Filter rule association             Add associated filter rule
- Save

--> Add (+)

- Interface                                WAN2
- Protocol                                 UDP
- Destination                            WAN1 address
- Destination port range           from:               to:
                                                OpenVPN        OpenVPN
-  Redirect target IP                 Single Host or Network
                                                127.0.0.1
- NAT reflection                       Use system default
- Filter rule association            Add associated filter rule
- Save


VPN --> OpenVPN --> Servers
--> Edit

- Interface                                Localhost
- Save
Title: Re: OpenVPN on Multi-WAN Environment
Post by: jasoncrowley on May 04, 2023, 01:53:35 pm
I'm resurrecting an old thread because I found a solution for our use case.

In our case, we had created an interface group under Firewall > Groups called WANAll. This allowed us to set firewall rules for our WAN1 and WAN2 interfaces in one place. We created the obligatory rule to allow port 1194 traffic for OpenVPN under WANAll instead of creating two separate firewall rules for WAN1 and WAN2.

The resulting pf rule looked like this:
Code: [Select]
pass in log quick on WANAll inet proto udp from any to (self) port = openvpn keep state label "0667d76bd1b44ab51c4eb85bb052e5e3"
We needed two separate rules, one for each WAN interface. I removed the rule under WANAll and created the rules separately under WAN1 and WAN2. The resulting pf rules look like this.
Code: [Select]
pass in log quick on igb1 reply-to (igb1 104.218.xxx.yyy) inet proto udp from any to (self) port = openvpn keep state label "2d1fd0c4c78f6823e4f74c3f01259251"
pass in log quick on igb2 reply-to (igb2 12.7.xxx.yyy) inet proto udp from any to (self) port = openvpn keep state label "1738df7680cf468ea2a66b684c810f64"

The reply-to clause is important. It tells pf that traffic entering on one interface should exit on the same interface. If the reply-to clause is not there, traffic destined to WAN2 will enter on WAN2 but response traffic will exit WAN1 because WAN1 has the higher-priority gateway (with a lower priority value). This causes an asymmetric routing problem where the response traffic never reaches its destination.