OPNsense Forum

English Forums => General Discussion => Topic started by: lenard220 on May 06, 2020, 07:26:55 PM

Title: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 06, 2020, 07:26:55 PM
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: bartjsmit on May 07, 2020, 09:50:56 AM
Have a look at your routing - there are three subnets in play:

- what your ISP router thinks of as the LAN
- what OPNsense thinks of as the LAN
- what the OpenVPN server brings up as a tunnel

All three routers need to know where all three subnets live or they'll just drop the packets.

Bart...
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 07, 2020, 03:50:06 PM
Hi,

thanks for your answer.

Quote- what your ISP router thinks of as the LAN
I'm not really sure what you mean by this. The only device on the LAN of the ISP router is the opnsense firewall / router.

Quote- what OPNsense thinks of as the LAN
OPNsense has several LAN's attached. "LAN_ext" which openvpn is connected to is one of them.
OPNsense has an outbound NAT configured so all packets gouing outside are addressed by the OPNsenses WAN IP.
OPNsenses WAN IP is in the subnet of the ISP routers lan.

Quote- what the OpenVPN server brings up as a tunnel
Do you mean the subnet? The openvpn tunnel has a seperate subnet (tun). The openvpn server nats the subnet so all packets going out of the openvpn server are addressed by the openvpn' s servers address. I have tested that the nat works and all outgoing packets are addressed by the openvpns servers ip address.

QuoteAll three routers need to know where all three subnets live or they'll just drop the packets.
Yes they can reach all subnets. On the ISP router I configured and tested the appropriate routes so I can reach all devices from the ISP routers LAN.

Regards

Lenard
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: bartjsmit on May 07, 2020, 10:38:50 PM
Hi Lenard,

Quote from: lenard220 on May 07, 2020, 03:50:06 PM
Yes they can reach all subnets. On the ISP router I configured and tested the appropriate routes so I can reach all devices from the ISP routers LAN.

It is not the reaching that is the problem if the router won't try it. For example take these as your subnet ranges:

internet (ISP) 192.168.123.0/24 (OPNsense) 10.43.36.0/24 (OpenVPN) 172.24.180.0/24

Let's say that OPNsense has 192.168.123.2 for its WAN and 10.43.36.1 assigned to the LAN, while the OpenVPN server has 10.43.36.2 for its Ethernet interface and 172.24.180.1 for its TUN interface.

The ISP router must have two static routes:
10.43.36.0/24 via 192.168.123.2
172.24.180.0/24 via 192.168.123.2

OPNsense must have the ISP router as its default gateway and one static route:
172.24.180.0/24 via 10.43.36.2

The OpenVPN server must have OPNsense as its default gateway and push 172.24.180.1 as the default gateway to its clients.

Your Debian server returns 1 on this command, doesn't it?

sudo cat /proc/sys/net/ipv4/ip_forward

Bart...
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 07, 2020, 11:16:11 PM
Hi,

my configuration is almost exactly like that.
By almost I mean that the only difference is that I NAT the openvpn tun subnet.
This means that as far as I know I do not need to have a static route to the openvpn subnet since nat repleaces the address with the openvpn servers address.
I have tested this by connecting to the openvpn server inside opnsense and then connecting to my webserver which reported the connected IP as the openvpns server ip. Later on I tested this with wireshark as well and it showed the same result so my NAT seems to work.

The problem is not that I can connect to the openvpn server and then can't reach anything. That would be the case if there would be a missing route to the openvpn subnet.
My problem is that while establishing the connection some packets are dropped, which causes the establishing of the connection to timeout.
The dropped packets have the exact same source and target address and the exact same port as the first packet which can go through the firewall. (Please see attached screenshots on the first post).

Regarding your last point:
QuoteYour Debian server returns 1 on this command, doesn't it?

sudo cat /proc/sys/net/ipv4/ip_forward

Yes it does.


Regards

Lenard
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 17, 2020, 12:34:13 AM
Update.

So I got recommened to try it out with tcp instead of udp.
For some reason tcp works completely fine.
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 18, 2020, 06:50:28 PM
Does anyone have an idea why udp is not working?
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: miroco on May 19, 2020, 12:34:36 AM
These are my settings.


miroco
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 19, 2020, 06:47:07 PM
Hi,

thanks for your answer.
I did test your settings and the problem is still there.

Regards

Lenard
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: bartjsmit on May 20, 2020, 12:36:05 PM
Hi Lenard, I think your problem is with the double NAT.

Quote from: lenard220 on May 07, 2020, 03:50:06 PMOPNsense has an outbound NAT configured so all packets gouing outside are addressed by the OPNsenses WAN IP.

Quote from: lenard220 on May 06, 2020, 07:26:55 PM
I have forwarded a bunch of ports including 1194 to my OPNsense and then forwarded 1194 to my openvpn server from there.

Unlike TCP, UDP is stateless and not easy to track across two NAT's. Can you try OPNsense without NAT (with the static routes), in bridge mode, or set your ISP router in modem mode?

Bart...
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: lenard220 on May 21, 2020, 01:12:58 AM
Hi Bart,

thanks for your answer.
So my ISP Router sadly doesn't allow using it as a modem only.
Setting the static routes works just fine.

So I did what you said, disabled NAT and only used Port Forwarding on OPNsense.
Mind you the port is still forwaded to the OPNsense's WAN IP.
Aaaaaaand it's fixed.

So for some reason the double NAT bricks OpenVPN.
But only especially OpenVPN and only when establishing a connection.

Thanks.

Regards

Lenard
Title: Re: OPNsense myteriously blocking OpenVPN traffic
Post by: bartjsmit on May 21, 2020, 07:50:41 AM
Hi Lenard, glad you got it fixed - you should try VoIP over NAT  :P