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

Messages - sesquipedality

#16
Can confirm that this fix worked for me.  I had to log in via IP and disable unbound prior to applying though, since DNS was not resolving while unbound was enabled.  Once the patch was applied, I could restart unbound.

Thanks for fixing this.
#17
Just to confirm I am observing this problem on 20.7.7 as well. I have reverted unbound as per the instructions above.
#18
20.7 Legacy Series / Re: Memory/swap issues
December 15, 2020, 11:39:57 AM
Does anyone have any pointers on this. please?  Thanks.
#19
20.7 Legacy Series / Memory/swap issues
December 13, 2020, 11:17:29 AM
Hello all.  I am running into a nasty problem with current OpnSense which probably started sometime during the 20.7 release cycle (I certainly don't remember this happening before the 20.7 upgrade).  It is difficult to debug as the symptoms are that the router becomes unresponsive, and throws up errors due to killing processes because it is out of swap.  It seems like it might be some sort of memory leak, but that does not make much sense.  I am able to monitor memory usage easily because the router runs in a VM on a Dell R710 1u server, and I can see that of the 2G I have allocated only about 1.2G is in use by the VM even during this issue.   Normal memory usage as reported by OpnSense (not directly comparable to the usage reported outside the VM by by qemu) itself is about 500G in normal operation, 1.9G just after boot.  CARP is enabled, but does not kick in, presumably because the kernel level CARP interface remains functional even though the router itself does not.

I have checked the logs, and unfortunately the out of swap errors do not get logged.  In fact there seems to be nothing in the way of logging for at least 30 minutes before the router became unresponsive.  The only reference to swap I have in the logs is as follows:

2020-12-13T00:41:01 kernel warning: increase kern.maxswzone or reduce amount of swap.
2020-12-13T00:41:01 kernel warning: total configured swap (2097152 pages) exceeds maximum recommended amount (2002392 pages).


I thought that there was no swap configured on OpnSense, so I am confused by this.

The unresponsiveness usually occurs overnight, so if there is an intensive system job running overnight, this could be the cause.

Can anyone give me any pointers as to how to work out what is going wrong.  I have not tried to login on the console when the router is unresponsive, but the web interface does not respond at all.
#20
Thanks.  Happy to have that happen, but I don't think I can do it myself.
#21
I have finally managed to get Wireguard VPN set up.  While I do think it's a lot simpler than the old staples like OpenVPN, it's a little bit of a frustrating experience, and the OPNSense instructions, while good as far as they go, do (like much of OPNSense's documentation) rather assume that you already know what you are doing.    So, for people who want to get an easyish VPN up and running but don't necessarily know a lot about Wireguard, here are some tips from my experience.

1) Pre-reading is a really good idea.

Start at wireguard.com for a quick conceptual overview - https://www.wireguard.com/

Read the Wireguard OPNSense instructions carefully.  A lot of of the frustration I experienced was due to not understanding these instructions properly when I started out.  When I came back later, a lot of the answers to the problems I was having were actually there.   There are two example configs provided.  The first, site to site setup, at https://docs.opnsense.org/manual/how-tos/wireguard-s2s.html is for linking the networks at two remote sites.  My usage case focused on connecting individual remote client machines to my local network, so I relied upon the slightly unhelpfully named "road warrior" setup at https://docs.opnsense.org/manual/how-tos/wireguard-client.html.

2) Useful Wireguard concepts

Wireguard is designed with a "general case" and peer-to-peer philosophy in mind, that makes it slightly confusing in a client/server context.  Wireguard nodes are peers, the basic idea is that each peer has a private key and a public key.  If you know your own private key and the other end's public key, and the other end knows its private key and your public key, then you will be able to talk.  But you will also need to understand how your network topology fits into Wireguard's model.

Because nodes are peers and not clients and servers, some of the configuration you would usually do on a server actually takes place on the "client".   On the "server", you can (and should) restrict the addresses a "client" is allowed to present as, but access control is all done outside of Wireguard in the router itself - Wireguard only really handles the creation of the network interface.   If you are reliant on a non-public DNS server, your clients will need to be configured individually to use it.

DHCP is not really a thing with Wireguard.  The remote end decides what IP address it's asking for and the local end gets to say yes or no.  This is true for both ends.

One end (likely the server) is going to need a resolvable DNS name or a static IP.  The other end can be non-fixed and behind a firewall (although you will need to configure keepalive in the latter case), but without one "anchored" endpoint there is no way for the peers to find each other.

3) Shared Secrets

Wireguard provides a pre-shared secret key or PSK (referred to as "shared secret" in OPNSense) as an added layer of security.  This is another key that is known to both clients.  This is optional, and you can ignore it if you like.  Explanations as to how it improves security are sparse at best, but it appears to work by creating a hash with the public keys sent across the network, so your actual keys are never transmitted.   The OPNSense documentation doesn't really refer to this, but if you want to generate one, you can do it from the command line using "wg genpsk".  This key needs to be configured on both ends of the connection.

4) OPNSense configuration - server

Read the OPNSense docs first.

Some settings are not relevant in a client/server setup.  You do not need to set a DNS server on the server end, as this setting is for DNS servers on the remote end of the tunnel.  The "tunnel address" setting is slightly confusing, but you want it to be the IP address and netmask of the local end of the tunnel.  You pick the address, and it needs to be on a different logical network from the other networks on your router.  If you decide on 10.80.0.1 with netmask 255.255.255.0 (so allowing for up to 253 clients), this setting would be 10.80.0.1/24.  OPNSense will generate public and private keys for you when you save the local configuration.

You can use any port number not in use on the local machine for your server.  You will need access to this UDP port through your firewall so that "clients" can talk to it.

5) Client configuration

I found it easiest to create the client configurations outside of OPNSense and then copy the relevant details into the OPNSense GUI.  Wireguard is still relatively new, and there is not much in the way of GUI configuration, so you will likely have to become familiar with its config file format in any event.   Here is a sample client config.

[Interface]
Address = 10.80.0.5/24
ListenPort = 51870
PrivateKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
DNS = 10.10.0.1

[Peer]
PublicKey = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy=
PresharedKey = zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=
AllowedIPs = 0.0.0.0/0
Endpoint = my.fqdn.com:51820
PersistentKeepalive = 25


Running through these in order

(I) Interface section - configuration of the local end of the tunnel.
a) Address - the local tunnel endpoint address and network used by the client.  Again this must be otherwise unused on the client. 
b) Listenport - can be anything that's not used locally - if you're behind a firewall, the connection will be on a different port anyway.
c) PrivateKey - Wireguard generates these.  On Unix, the command "wg genkey | tee privatekey | wg pubkey > publickey" will put your key in the file "privatekey".  Remember to keep these secret - do not make these files world readable.
d) DNS - the name of your DNS server on the server network.  You need to set this if you are routing all traffic via the VPN.  You probably don't want to try to run a DNS server directly on the Wireguard interface, because it may not be able to bind to the interface at boot time.  Note that there is no current way to set a default DNS search prefix on Windows, so your Windows users will have to live with typing full domain names for your services.

(II) Peer section - information about the remote end
(a) PublicKey - the server's public key - you can take this from the OPNSense GUI - just edit the "local endpoint" and copy from there
(b) PresharedKey - must be the same for both ends of the tunnel.  Generate using "wg genpsk"
(c) AllowedIPs - 0.0.0.0/0 is the setting to tell this machine to route all of its traffic over the VPN when it is up.  You can alternatively set this only to route traffic to your secure network using e.g. "10.10.0.0/24,10.20.0.0/24"
(d) Endpoint - this is the public name and port of your server
(e) PersistentKeepalive - if your client will never be behind NAT you can leave this out, but if NAT is ever likely to be involved, you will need this to make sure that the firewall on the client end does not close the connection between client and server.

Confguring mobile clients can be painful.  There does not appear to be a qrencode package for OPNSense, but on a Unix system with qrencode installed, you can convert a config file into scanable format using "qrencode -t ansiutf8 -r client.conf" (make sure your terminal window is big enough).  This can then be scanned in in the Android (and possibly iOS) application.  (It may be that the OPNSense maintainers might want to include  graphics/libqrencode in their available packages so that people could install it if they wanted to, but it is rather a niche use case.)

(https://github.com/burghardt/easy-wg-quick is a script used to quickly generate config files for this type of installation which may be worth investigating if you have a lot of clients to set up, but plumbing its configuration in to OPNSense may take some thought.)

6) OPNSense configuration - client

Again, not all settings are relevant in this sort of setup.  Add the relevant ones from the "Endpoints" tab.   "Name" can be whatever you want to call the link.  "Public key" is the client's key as generated above, and "shared secret" is likewise your generated PSK.   "Allowed IPs" should be set to the IP address you want this client to connect as, so in the above example, you would set it to 10.80.0.5/32.  Note that you use a single host netmask, as there is only one IP address that this client is allowed to connect as and this link is not a route to anything other than this specific endpoint.  "Endpoint address" and "endpoint port" are likely to change and do not need to be configured.  You are unlikely to need "keepalive" here, as your server port is accessible via the firewall at all times.  The clients will set keepalive if they need it.

Don't forget to go back to add this endpoint to "peers" in your local endpoint to allow the connections to talk to each other.

6) Routing

This will depend hugely on your setup.  The official docs say that to allow routing to the Internet, you need to add the Wireguard interface to the OPNSense interfaces.   I wasn't able to get this to work, and didn't need to, so it may be that this is out of date.  For me, it was enough to add a firewall rule allowing traffic on the Wireguard interface to pass.   For outbound NAT rules I use a hybrid configuration that turns off NAT on the Wireguard interface (not sure if I need that or not) and after that I created duplicates of the auto-created rules, substituting the "WireGuard" net for my local networks.  In all honestly I find the OPNSense firewall to be a bit of a black art, and there may be a better way to do this, but it seems to work for me.

7) Troubleshooting

Wireguard's diagnostics are, frankly, utterly rubbish, but OPNSense does provide you with most of the info available.  You may also find it helpful to use "tcpdump -i wg0" from the router on the command line interface to monitor the traffic on the VPN link.

OPNSense's "list configuration" tab shows your currently configured tunnels.  If a client is not showing up here, then you probably forgot to add it as a peer to the local endpoint.  If "allowed IPs" is blank, that may be a symptom of an incorrectly configured tunnel.  "Latest handshake" shows when a client last connected - if it's not there, then your tunnel is not working, but bear in mind it can take a short while for the tunnel to come up after you restart it.  Similarly the "Handshakes" tab will show you if a client has connected since you last restarted Wireguard on the server (if the number on the right corresponding to the public key of the link is not 0) so may also be useful.  You can stop and restart Wireguard on the router to reset these if you need to.

Hopefully this info will be useful to someone who, like me, was having trouble getting things to work.
#22
I have two OpnSense routers set up, router1 is connected to Virgin, router 2 to Vodafone. Router1 and router2 are in a CARP group, and router2 takes over from router1 as DNS and DHCP server in the event it goes down.   In addition to LAN links, there is a direct back to back link between the two machines.  The setup for router1 is thus

LAN: 192.168.37.5/24
Backbone: 192.168.66.5/24 - point to point with 192.168.66.4
WAN: <wan address>
CARP: 192.168.37.1/24


And router 2 is on .4 with a mirror configuration

I have manually configured a gateway, BACKBONE_STATIC with address 192.168.66.4, it is set as an upstream gateway, but not as a far gateway, and in practice, neither of those settings seems to make a difference.  Priority is the default 255.

The external interface and the backbone link are in a WAN group together, with the external uplink as Tier 1 and the backbone as Tier 2.  The backbone interface has a default firewall rule to allow all traffic, and also, there is a custom outbound NAT rule saying not to NAT the backbone ahead of the auto-generated rules.

This configuration works, and as expected there is failover to the backbone link if the Virgin connection goes down.  The problem is that monitoring seems extremely flakey.   If the WAN on router2 is up when I configure the backbone link, it comes up and continues to show as online even if I take the WAN on router2 down.  If the WAN on router2 is down when I configure monitoring, the backbone link shows as offline and does not come back.

I thought this might be an asymmetric routing issue i.e. that router2 does not send the returning packets back via 192.168.66.5, but enabling the "bind states to interface" firewall option on both routers does not change this behaviour.  Adding a static route to 0.0.0.0/0 via 192.168.66.4 similarly makes no difference.   How do I get this setup to work properly?

As a side note, using Cloudflare DNS (i.e. 1.1.1.1) as a remote target for dpinger does not seem to work.  The OPNsense examples all use Google's Public DNS as a suggested endpoint, but this is only helpful if you only have two WAN links.   Are there any other good IPs to use with gateway monitoring?
#23
I think that option 1 may be achievable using scripting.  If we set CARP base to 1 with skew 0 on router1 and base to 1 with skew 50 on router2, then it should theoretically be possible to force router1 to CARP state backup by using

sysctl net.inet.carp.demotion=100

And then when the link comes back allow it to become master again by using

sysctl net.inet.carp.demotion=-100

The issue then becomes how to detect no traffic on the wan.  I've looked at what monit is doing, but its gateway monitoring doesn't appear to give any more detail than a change in state, and I'm not sure how to integrate a script into it anyway.

is there some way to pull this status from OPNsense?  Ideally I'd want this to be checking every second.  I have literally no PHP skills, so something I can use from a bash script would be ideal.

(Source for the CARP configuration: https://lists.freebsd.org/pipermail/freebsd-stable/2017-March/086882.html)
#24
20.1 Legacy Series / Re: Redundant DNS
July 05, 2020, 11:02:57 AM
In the end, I solved this by creating a second OPNsense router, following the High Availability guide on the website, but only for the local interface, and selectively syncing DHCP and unbound to the backup server.  I then changed the DHCP settings to use the CARP address for DNS.

One slight wrinkle was that  I had to add an explicit firewall rule allowing DNS traffic to the local network CARP address on both machines, although I am still not entirely sure why that was necessary.
#25
My current OPNSense config involves 2 opnsense routers - call them "router1" and "router2".  Router1 connects to a Virgin uplink.  Router2 connects to a Vodafone uplink.   Both routers share a CARP virtual IP, 192.168.5.1, with router1 having higher priority and being the master.  They do not share firewall config because they have different interfaces attached, but dhcp and unbound are synced across from router1 to router2 using the OPNsense HA features on a dedicated direct static ethernet link between them.  The network is configured to use the CARP address for DNS and routing.

What works OK - when router1 goes down, router2 transparently takes over, and there is no interruption in network service.

What doesn't work OK - when the Virgin router goes down, router1 keeps hold of the CARP link and does not allow router2 to step in.

I've played about with trying to create a multi-WAN gateway to route traffic to the internet via the dedicated link from router1 to router2 on router1, but I can't even get the gateway to come up.  Adding a static route to 0.0.0.0/0 via the dedicated interface didn't help, nor did enabling the "static route filtering" option on router1.

What I'd like to be able to do is one of the following

1) Have router2 become the CARP master when router1 has no internet access; or
2) Allow router1 to send internet traffic via router2 when its own  uplink is down

What is the best way to achieve this, please?
#26
20.1 Legacy Series / Re: Redundant DNS
July 01, 2020, 03:07:06 PM
Thanks.

Yes, it is local caching plus aliases, which suggests the replicating the Unbound config would get me most of the way.

However, that still leaves the problems of how to keep unbound's cache of DHCP hosts in sync, since only the router will be serving DHCP.  Getting the secondary to host DHCP too would not solve this problem as then it would be pot luck as to which DNS server contained the A record associated with a given lease.

I'm starting to wonder here if the answer isn't another minimally configured OpnSense server which uses the HA/Replication features to provide DNS and DHCP.
#27
20.1 Legacy Series / Re: Redundant DNS
June 30, 2020, 07:48:44 PM
I am entirely happy with running another box / docker container - it's more about the "how".  In particular, I would need it to serve the same aliases as unbound does.
#28
20.1 Legacy Series / Redundant DNS
June 30, 2020, 07:20:22 PM
I'd like my local network to be a bit more robust on internal DNS if the router goes down.  I could create a second OpnSense machine, but that seems like overkill.  All I really want to do is have a second DNS server, which copies all the configuration on the OpnSense box, and can be referred to if the primary server goes down.

Is there a good way to accomplish this?
#29
If you are using unbound on the opnsense router to serve DNS on your network, you can possibly avoid the need for NAT reflection by using a DNS alias instead.  Set it so that your public hostname resolves to your internal IP, and all should be well.

I tried and gave up with NAT reflection because I found it had too many odd side effects for my liking.  If the above solution doesn't work for you, then hopefully someone else will be able to assist.
#30
Thanks, this is useful data.   Iniitally I tried setting up two DNS servers for each uplink, but that didn't seem to work at all so I reduced to a single DNS server per uplink (i.e. two in total), which allowed things to work to the extent that they do right now.   DNS problems is certainly consistent with some of the symptoms I have observed, but it's difficult to know what else could be done.  If DNS is the problem, it's unlikely that the physical links are what's causing the difficulty here.  I'm still at somewhat of a loss as to where to start in tracking down or fixing the problem though.