Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - KeyHand

#1
I have been testing OPNsense in a virtualised environment (KVM) with modest resources (10GB disk, 4GB memory, 4 cores).  The logic being it if behaves well here, it'll work just fine with more resources.

When investigating how OPNsense handles writing logs to disk, I enabled the '/var RAM disk' option in 'System: Settings: Miscellaneous'.  With conservative logging options set in 'System: Settings: Logging' ('Disable circular logs': checked, 'Preserve logs (Days)': 5) and only basic services running on the system (pf, dhcp, unbound DNS), this worked just fine.

The problem came with enabling more services.  Specifically NetFlow (required by 'Reporting: Insight'), ntopng (installed as a plugin) and redis (a required dependency of ntopng).  Everything would work fine for a while, but certain aspects of the system would become unresponsive after some time had passed.  Most noticeably unbound refused to respond to queries.  The services widget on the dashboard would show unbound and flowd_aggregate as stopped.  Manually restarting them again would work for a few minutes, but eventually they would stop again.  The dashboard also showed high memory usage and disk usage on `/var`; not surprising given the additional services running on the system.

The only place that provided a hint as to what was happening was the OPNsense console: the system was running out of memory and killing processes.  Unfortunately I didn't think to save the exact error messages at the time.  (Does OPNsense regularly save `dmesg` output to a file?)

NetFilter, ntopng and redis obviously require memory to operate.  The compounding factor is those services persisting a significant amount of data to memory-backed storage.  In the case of NetFilter, it's actually a spiral of doom: `/var/log/flowd.log*` files produced by NetFliter are rotated by `flowd_aggregate`, which gets killed due to low memory conditions.

Looking at how the '/var RAM disk' option works, it simply triggers creation of tmpfs with minimal options.  I.e.


mount -t tmpfs tmpfs /var


For reference, enabling '/tmp RAM disk' does something similar

mount -t tmpfs -o mode=01777 tmpfs /tmp

When no `size` parameter is specified, `tmpfs` defaults to using all of the available memory.

Quote

     size   Specifies the total file system size in bytes, unless
            suffixed with one of k, m, g, t, or p, which denote
            byte, kilobyte, megabyte, gigabyte, terabyte and
            petabyte respectively.  If zero (the default) or a
            value larger than SIZE_MAX - PAGE_SIZE is given, the
            available amount of memory (including main memory and
            swap space) will be used.


Understandably, having this particular combination of memory- and disk-hungry applications running on a system with constrained resources isn't a great idea.  However I imagine there are legitimate cases where having a tmpfs-backed `/var` is desirable, and it would be preferable to exhaust logging space before the system runs out of memory and starts killing off processes.

When using '/var RAM disk' option in 'System: Settings: Miscellaneous', can tmpfs be capped at a size less than total system memory?  Preferably user defined, either expressed as a percentage of system memory or an explicit value.
#2
I'm configuring a new OPNsense instance and have been rebooting the system quite frequently when testing.  Each time the system comes back up I'm faced with an `ERR_SSL_PROTOCOL_ERROR` when attempting to access the web interface.

Searching around for similar issues, I found that running

configctl webgui restart

from the console was enough to regain access to the web interface.  Granted I won't intentionally be rebooting the system very frequently.  But this is the last thing I'd want to be dealing with after an unexpected restart.

Can anyone shed some light on what's happening here?
#3
I'm in the process of setting up a new OPNsense installation and have so far configured

  • several subnets on multiple VLANs
  • a number of OpenVPN and WireGuard interfaces in client mode
  • firewall and NAT rules to enable selective traffic routing for hosts in the VLAN subnets over the VPN links
For hosts on the various LAN segments, everything is working as it should.  The problem is getting OPNsense itself to use these interfaces for outbound traffic, with the specific use case of having Unbound use the WireGuard and OpenVPN interfaces for all outbound requests; something I have working in other pfSense installations.

As the traffic is originating from the firewall itself, no outbound NAT should be required.  However, when troubleshooting this issue, I tried creating NAT rules and it did not made a difference.  The firewall logs do not show any traffic explicitly being blocked, not even a 'default deny'.  I even turned on logging for every single firewall rule in the system, which only resulted in a wall of 'let out anything from firewall host itself' messages.

`pftop` shows the following in these scenarios:

1. Configuring Unbound to explicitly use the WAN interface, then running `drill google.com` on the firewall


udp      Out 127.0.0.1:58049          127.0.0.1:53               MULTIPLE:SINGLE       00:00:13  00:00:17        2      116
udp      Out <WAN_IP>:24639        198.97.190.53:53           MULTIPLE:SINGLE       00:00:08  00:00:22        2      802
udp      Out <WAN_IP>:62446        202.12.27.33:53            MULTIPLE:SINGLE       00:00:05  00:00:25        2     1181
udp      Out 127.0.0.1:36195          127.0.0.1:53               MULTIPLE:SINGLE       00:00:04  00:00:26        2      164
udp      Out 127.0.0.1:54392          127.0.0.1:53               MULTIPLE:SINGLE       00:00:37  00:00:00        2      136
udp      Out <WAN_IP>:29434        193.0.14.129:53            MULTIPLE:SINGLE       00:00:05  00:00:25        2     1181
udp      Out <WAN_IP>:4269         198.97.190.53:53           MULTIPLE:SINGLE       00:00:05  00:00:25        2      701
udp      Out <WAN_IP>:24497        192.112.36.4:53            MULTIPLE:SINGLE       00:00:05  00:00:25        2      701
udp      Out <WAN_IP>:50107        65.22.160.17:53            MULTIPLE:SINGLE       00:00:05  00:00:25        2      415


2. Configuring Unbound to explicitly use the the OpenVPN and WireGuard interfaces, then running `drill google.com` on the firewall

PR       DIR SRC                      DEST                             STATE                AGE       EXP     PKTS    BYTES
udp      Out <OVPN1_IP>:60017           193.0.14.129:53              SINGLE:NO_TRAFFIC   00:00:15  00:00:45        1       56
udp      Out <OVPN2_IP>:42628           192.5.5.241:53               SINGLE:NO_TRAFFIC   00:00:10  00:00:50        1       56
udp      Out <WG1_IP>:40007           192.33.4.12:53               SINGLE:NO_TRAFFIC   00:00:09  00:00:51        1       56
udp      Out <OVPN1_IP>:53387           199.7.91.13:53               SINGLE:NO_TRAFFIC   00:00:09  00:00:51        1       56
udp      Out <OVPN1_IP>:57877           199.7.83.42:53               SINGLE:NO_TRAFFIC   00:00:07  00:00:53        1       56
udp      Out <OVPN2_IP>:8751            199.7.83.42:53               SINGLE:NO_TRAFFIC   00:00:06  00:00:54        1       56
udp      Out <OVPN1_IP>:18903           199.9.14.201:53              SINGLE:NO_TRAFFIC   00:00:06  00:00:54        1       56
udp      Out <OVPN2_IP>:10430           192.5.5.241:53               SINGLE:NO_TRAFFIC   00:00:05  00:00:55        1       56
udp      Out <OVPN2_IP>:63408           192.5.5.241:53               SINGLE:NO_TRAFFIC   00:00:04  00:00:56        1       56
udp      Out <OVPN2_IP>:44057           202.12.27.33:53              SINGLE:NO_TRAFFIC   00:00:04  00:00:56        1       56
udp      Out <WG1_IP>:52863           198.97.190.53:53             SINGLE:NO_TRAFFIC   00:00:03  00:00:57        1       56
udp      Out <OVPN1_IP>:54187           202.12.27.33:53              SINGLE:NO_TRAFFIC   00:00:03  00:00:57        1       56
udp      Out <WG1_IP>:36030           192.58.128.30:53             SINGLE:NO_TRAFFIC   00:00:01  00:00:59        1       56
udp      Out <WG1_IP>:43964           192.203.230.10:53            SINGLE:NO_TRAFFIC   00:00:00  00:01:00        1       56
udp      Out <WG1_IP>:16896           198.41.0.4:53                SINGLE:NO_TRAFFIC   00:00:14  00:00:46        1       56
udp      Out <WG1_IP>:44421           198.41.0.4:53                SINGLE:NO_TRAFFIC   00:00:14  00:00:46        1       56
udp      Out <OVPN1_IP>:51771           192.58.128.30:53             SINGLE:NO_TRAFFIC   00:00:13  00:00:47        1       56


3. Running `curl -L http://1.1.1.1` on the firewall


tcp      Out <WAN_IP>:5919         1.1.1.1:80               FIN_WAIT_2:FIN_WAIT_2   00:00:04  00:01:26       10      938


4. Running `curl -L --interface ovpnc1 http://1.1.1.1` on the firewall


tcp      Out <OVPN_IP>:24788           1.1.1.1:80                 SYN_SENT:CLOSED       00:00:07  00:00:26        3      180


Have I overlooked a simple configuration option?  If so, I would really appreciate if someone could point me in the right direction.