{"id":5734,"date":"2025-05-10T12:30:00","date_gmt":"2025-05-10T11:30:00","guid":{"rendered":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/?page_id=5734"},"modified":"2026-02-04T11:20:06","modified_gmt":"2026-02-04T11:20:06","slug":"opnsense-miscellaneous-hints-and-tips","status":"publish","type":"page","link":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/?page_id=5734","title":{"rendered":"OPNsense &#8211; Miscellaneous Hints and Tips"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Ping not working from WAN interface<\/h2>\n\n\n\n<p>This seemed really strange; in a test configuration, where the &#8220;WAN&#8221; connection for OPNsense was in fact an existing (but not OPNsense) packet-filtering firewall, the WAN interface was happily being allocated an IP address by DHCP but it wasn&#8217;t possible to get a &#8216;ping&#8217; response from the next-hop Gateway. Looking at the packets on the network, it was clear the ICMP packets were indeed being sent &#8211; and responded to &#8211; but these replies were never being seen by the &#8216;ping&#8217; command. As a consequence of &#8216;ping&#8217; not working, the status monitoring on the WAN interface was failing, considering it to be always &#8216;down&#8217; &#8211; and so not routing any traffic to it.<\/p>\n\n\n\n<p>The solution came via <a href=\"https:\/\/www.reddit.com\/r\/OPNsenseFirewall\/comments\/15o6doq\/comment\/jvstpl1\/?utm_source=share&amp;utm_medium=web3x&amp;utm_name=web3xcss&amp;utm_term=1&amp;utm_content=share_button\" target=\"_blank\" rel=\"noreferrer noopener\">this Reddit post<\/a>, which says:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Check firewall &gt; settings &gt; advanced. Change the &#8220;reply-to on wan rules&#8221; to the opposite.<\/p>\n<\/blockquote>\n\n\n\n<p>This is referring to the &#8220;Disable reply-to on WAN rules&#8221; tick-box, for which the additional help text says:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>With Multi-WAN you generally want to ensure traffic leaves the same interface it arrives on, hence reply-to is added automatically by default. When using bridging, you must disable this behaviour if the WAN gateway IP is different from the gateway IP of the hosts behind the bridged interface.<\/p>\n<\/blockquote>\n\n\n\n<p>The OPNsense manual page for this setting is <a href=\"https:\/\/docs.opnsense.org\/manual\/firewall_settings.html#disable-reply-to\">here<\/a>. It&#8217;s not clear how Bridging is related to this &#8211; there <strong>is<\/strong> a Bridge interface for one of the LAN VLANs; maybe the Tunable configuration settings required for that Bridge change the behaviour for the WAN interface too?<\/p>\n\n\n\n<p>From some further reading, it seems the problem only manifests itself when the next-hop gateway is itself a packet-filtering firewall, so it might not be an issue in a more realistic deployment scenario.<\/p>\n\n\n\n<p>There&#8217;s an in-depth discussion in this OPNsense Community posts: <a href=\"https:\/\/forum.opnsense.org\/index.php?topic=15900.0\" target=\"_blank\" rel=\"noreferrer noopener\">Reply-to on WAN by default is bogus<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">possible DNS-rebind attack detected:<\/h2>\n\n\n\n<p>Admittedly it&#8217;s a slightly unusual deployment scenario to have one DNS server running in the Outbuildings, referencing <em>another<\/em> DNS server running in the House &#8211; where both the House and the Outbuildings are using RFC1918 &#8216;private&#8217; IP address ranges. One consequence of this deployment pattern is that the Outbuildings DNS server treats the receipt of an RFC1918 IP address from its upstream DNS server as a &#8220;<em>possible DNS-rebind attack<\/em>&#8221; &#8211; because dnsmasq is configured (by OPNsense) with <code>stop-dns-rebind<\/code> in its configuration file.<\/p>\n\n\n\n<p>There&#8217;s certainly a requirement for the Outbuildings&#8217; DNS server to return IP addresses for hostnames such as <code>unifi<\/code> (so UniFi network equipment knows where to find its Controller) which trigger the &#8216;rebind attack&#8217; error if the response comes from the House&#8217;s DNS server.<\/p>\n\n\n\n<p>One option is to add a duplicate, local entry for <code>unifi<\/code> to the Outbuildings&#8217; DNS server, since that avoids triggering the error (because the entry is &#8216;local&#8217;) &#8211; but it means maintaining a duplicate entry on both DNS servers.<\/p>\n\n\n\n<p>Another option is to use the <code>rebind-domain-ok=\/unifi\/<\/code> dnsmasq configuration syntax to specify domain names which should be permitted RFC1918 addresses. Since this construct is not supported by OPNsense&#8217;s GUI for dnsmasq, such configuration lines need adding to a custom <code>.conf<\/code> file placed in directory <code>\/usr\/local\/etc\/dnsmasq.conf.d\/<\/code> While this works OK it&#8217;s a bit of a pain to have to maintain entries for all hosts in the House.<\/p>\n\n\n\n<p>A third option is to <strong>not<\/strong> to specify <code>stop-dns-rebind<\/code> in the dnsmasq configuration file (and hence turn off rebind checking completely, for the Outbuildings&#8217; DNS server) &#8211; but this line is automatically added to the main <code>dnsmasq.conf<\/code> file by OPNsense and there is no GUI option to remove it. It appears that the same result can be achieved by adding the following in a custom <code>.conf<\/code> file &#8211; which effectively says that &#8216;all hosts&#8217; are <code>rebind-domain-ok<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rebind-domain-ok=<\/code><\/pre>\n\n\n\n<p>A related point is that none of the DHCP host address reservations should have the &#8216;Local&#8217; box ticked, since doing so declares the specified Domain will only be served by the local DNS server &#8211; and never forwarded upstream.<\/p>\n\n\n\n<p>In the end, the all-round better solution turned out to be to centralise DHCP and DNS on the House firewall, using DHCP Relay settings on the local VLANs in the Outbuildings. A side-effect of this is that the DHCP leases returned by the House&#8217;s DHCP server automatically reference the House&#8217;s DNS server, so there&#8217;s only one DNS server that ever returns RFC1918 addresses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">TCP Session Timeout<\/h2>\n\n\n\n<p>Kept noticing packets tripping the &#8220;Default deny \/ state violation rule&#8221; when on inspection they belonged to legitimate traffic &#8211; so they were clearly failing on the &#8216;state&#8217; element of the check.<\/p>\n\n\n\n<p>There&#8217;s an Advanced Setting for the Firewall of &#8220;Firewall Optimization&#8221; which is &#8220;Normal&#8221; by default; changing this to &#8220;Conservative&#8221; seems to be helping to avoid this traffic being blocked unnecessarily.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checklist for Adding an Extra VLAN<\/h2>\n\n\n\n<p>Adding a new VLAN isn&#8217;t difficult but there are quite a few steps required, some of which must be performed in a specific order.<\/p>\n\n\n\n<p>The first step is to allocate the configuration settings for the new VLAN, notably:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The numeric VLAN ID<\/li>\n\n\n\n<li>The four-character alphabetic name (referenced as <code><em>AAAA<\/em><\/code> below)<\/li>\n\n\n\n<li>The IPv4 subnet<\/li>\n\n\n\n<li>The IPv6 &#8216;prefix&#8217; tracked from the WAN interface<\/li>\n<\/ul>\n\n\n\n<p>If this is going to be a &#8216;bridged&#8217; VLAN (i.e. stretched between the two buildings \/ routers):<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create the VLAN device on the LAGG side of the House firewall\n<ul class=\"wp-block-list\">\n<li>The Device name should be <code>vlan0<strong>1<\/strong>.nnnn<\/code> where <code>nnnn<\/code> is the numeric VLAN ID, padded to 4 digits (e.g. <code>0080<\/code>)<\/li>\n\n\n\n<li>The Parent must be <code>lagg0<\/code> (LAGG)<\/li>\n\n\n\n<li>The Description should be be <code>L_nnnn<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create the VLAN device on the BACK side of the House firewall\n<ul class=\"wp-block-list\">\n<li>The Device name should be <code>vlan0<strong>2<\/strong>.nnnn<\/code> where <code>nnnn<\/code> is the numeric VLAN ID, padded to 4 digits (e.g. <code>0080<\/code>)<\/li>\n\n\n\n<li>The Parent must be <code>igb4<\/code> (BACK)<\/li>\n\n\n\n<li>The Description should be be <code>B_nnnn<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Assign both of these VLAN devices (to <code>L_nnnn<\/code> and <code>B_nnnn<\/code> respectively)<\/li>\n\n\n\n<li>Add both of these VLAN device assignments to the <code>Bridge_Parents<\/code> Group (under &#8216;Firewall&#8217;)<\/li>\n\n\n\n<li>Create the Bridge device, choosing the VLAN device assignments as the Member Interfaces and adding a Description of: <code>Bridge for <em>AAAA<\/em> VLAN<\/code><\/li>\n\n\n\n<li>Assign the Bridge device, changing the name to just <code><em>AAAA<\/em><\/code> and being sure to Enable and Lock the interface\n<ul class=\"wp-block-list\">\n<li>Set the &#8216;IPv4 Configuration Type&#8217; to <code>Static IPv4<\/code> and enter the IPv4 details further down\n<ul class=\"wp-block-list\">\n<li>The interface address will normally be <code>172.16.<em>nn<\/em>.1<\/code> and the CIDR suffix will normally be <code>\/22<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Set the &#8216;IPv6 Configuration Type&#8217; to <code>Track Interface<\/code> and enter the relevant Track Interface &#8216;prefix&#8217; allocated earlier<\/li>\n\n\n\n<li>Add the Bridge device to the <code>Local_VLANs<\/code> Group (under &#8216;Firewall&#8217;)<\/li>\n\n\n\n<li>Add the new Subnet to DNSMASQ\n<ul class=\"wp-block-list\">\n<li>Add it to the list of Interfaces to be served<\/li>\n\n\n\n<li>Add a DHCP Range for it, normally <code>172.16.nn+2.1<\/code> through <code>172.16.nn+3.254<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create the VLAN device on the LAGG side of the Outbuildings firewall<\/li>\n\n\n\n<li>Create the VLAN device on the BACK side of the Outbuildings firewall<\/li>\n\n\n\n<li>Assign those and add them to the <code>Bridge_Parents<\/code> Group<\/li>\n\n\n\n<li>Create the Bridge device on the Outbuildings firewall<\/li>\n\n\n\n<li>Assign the Bridge device but do not Enable it (but do Lock it)<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">APC UPS Monitoring<\/h2>\n\n\n\n<p>While there is Uninterruptible Power Supply protection on both of the OPNsense installations, those UPSes are only expected to cover a couple of seconds of outage while the Tesla Backup Gateway switches the whole site over to battery power. It therefore doesn&#8217;t seem necessary to configure a controlled shutdown of OPNsense when the UPS is about to shutdown because its battery is almost empty.<\/p>\n\n\n\n<p>However, it can be useful to have visibility of UPS battery health which one of the UPS monitoring utilities can provide. As a long-time user of APS UPS devices I was aware of the <a href=\"http:\/\/www.apcupsd.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">APC UPS Daemon (apcupsd)<\/a> but read some reports that <a href=\"https:\/\/networkupstools.org\" target=\"_blank\" rel=\"noreferrer noopener\">Network UPS Tools<\/a> is generally preferred &#8211; mostly because it is still being actively developed (whereas apcupsd is not).<\/p>\n\n\n\n<p>Both utilities are available as OPNsense plugins but NUT proved problematic with a USB-connected UPS. The UPS was being recognised by the Kernel with no issue:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># usbconfig\nugen1.1: &lt;EHCI root HUB AMD> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)\nugen0.1: &lt;XHCI root HUB AMD> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)\nugen1.2: &lt;Root Hub Advanced Micro Devices, Inc.> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)\n<strong>ugen0.2: &lt;Uninterruptible Power Supply American Power Conversion> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (0mA)<\/strong><\/code><\/pre>\n\n\n\n<p>However there were error messages suggesting NUT was not able to auto-detect the USB-connected UPS, perhaps due to permission issues:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># upsdrvctl start\nNetwork UPS Tools - UPS driver controller 2.8.2\nNetwork UPS Tools - Generic HID driver 0.53 (2.8.2)\nUSB communication driver (libusb 1.0) 0.47\n<strong>libusb1: Could not open any HID devices: no USB buses found\nNo matching HID UPS found<\/strong>\nupsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it\nDriver failed to start (exit status=1)<\/code><\/pre>\n\n\n\n<p>A bit of research turned up some matching error reports &#8211; notably <a href=\"https:\/\/forum.opnsense.org\/index.php?topic=28682.0\" target=\"_blank\" rel=\"noreferrer noopener\">NUT Doesn&#8217;t Find USB Buses<\/a> &#8211;  with some pointers to workarounds based on setting Tuneables to stop the Kernel attaching its own USB driver.<\/p>\n\n\n\n<p>Trying apsupsd instead, that &#8216;just worked&#8217; and immediately showed a status page with a whole bunch of details retrieved from the UPS. Looks like that will be the better option &#8211; especially since both UPS devices are from APC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ping not working from WAN interface This seemed really strange; in a test configuration, where the &#8220;WAN&#8221; connection for OPNsense was in fact an existing (but not OPNsense) packet-filtering firewall, the WAN interface was happily being allocated an IP address &hellip; <a href=\"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/?page_id=5734\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":5732,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5734","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5734"}],"version-history":[{"count":8,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5734\/revisions"}],"predecessor-version":[{"id":7162,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5734\/revisions\/7162"}],"up":[{"embeddable":true,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5732"}],"wp:attachment":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}