Virtual IP on WAN with 1:1 NAT breaks WAN gateway
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
- [x] I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
- [x] I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue
Describe the bug
On a very basic OPNsense instance (details below under environment), the creation of a virtual IP on the working WAN interface, followed by activation of a one to one NAT rule for that Virtual IP (source) to an internal IP on the LAN (dest) with default values otherwise makes the WAN gateway immediately unreachable. That means, log is flooded with
dpinger[67580] | WAN_GW XX.XX.XX.XX: sendto error: 64
and the gateway is soon considered down. The logs are true, OPNsense is then indeed completely locked out from the outside (i.e. access is only possible from LAN).
Interestingly, at that point, disabling the NAT rule doesn't recover this failure state. The virtual IP has to be removed, too. However, creating a virtual IP alone without the corresponding NAT rule doesn't trigger the failure.
To Reproduce
- Set up OPNsense with settings/environment as specified below.
- Define virtual IP
- Create and activate NAT rule
- Cry
Expected behavior
Well, defining vIPs on the WAN interface and using them in NAT rules shouldn't break the WAN gateway connection.
Screenshots
-
Relevant log files
The logs mentioned above doesn't contain anything more interisting than that, but I'm happy to provide other logs if needed/helpful.
Additional context
I found a few internet discussions where exactly this issue appeared (this one seems to be a perfect fit [german]: forum.opnsense.org/index.php?topic=13786.0) but none of them had a solution. Interest there seemed quite low, so I'm guessing this has to appear only in very specific circumstances or is just a really dumb configuration mistake so that the problem magically solves itself and no one thinks about sharing it. However, postings from above show this also happened like at least two years ago.
Environment
Network:
- Proxmox host with one physical NIC.
- Bridge vmbr0 mapped to that physical interface, added to OPNsense VM.
- vmbr0 (i.e. the physical host interface) has a public IP, let's assume 111.111.111.111 here.
- Bridge vmbr1 for internal LAN, also added to OPNsense VM (10.0.0.0/24).
- OPNsense VM has a dedicated public IP (from VPS with it's own MAC address) that is configured on vmbr0 within OPNsense, let's call it 111.111.111.222
- vmbr0 is OPNsense's WAN.
- vmbr1 is OPNsense's LAN.
- Everything 'works' and is reachable (PM Host, OPNS, also other VMs if present when connected to vmbr1 with 10.0.0.0/24 access).
- An extra subnet from VPS shall be used to make some VMs publicly reachable through OPNsense's NAT. This subnet is routed through the main IP, 111.111.111.111
- Thus, the IPs from that subnet shall be made known to OPNsense (as virtual IPs)
- vmbr0 is configured to forward (aka
up sysctl -w net.ipv4.ip_forward=1within the interface config)
OPNsense:
- v21.1.6
- FreeBSD 12.1-RELEASE-p16-HBSD
- OpenSSL 1.1.1k
- 2 cores @ 2.8 GHz, 4 GB RAM
- Plugins:
- os-qemu-guest-agent
- os-acme-client
- os-dyndns
- OpenVPN server configured,
- No other extra-configurations except basic WAN & LAN on first login
Today I decided to set up OPNS from scratch. This time I even left out OpenVPN and DNS configuration and did only the bare minimum.
Turns out: It works and seemed to be a configuration mistake on the proxmox side. While reconfiguring the VM, I noticed that the pointopoint and gateway entry on vmbr0 (proxmox host side) where wrong, they didn't specify the correct IP. Apart from OPNS, this didn't result in an obvious failure so I didn't notice this mistake earlier.
Hope this may at least motivate someone else stumpling across this to double check the host side even though it may seem to be correct at first glance.