Home

OpenWrt & fail2ban

$$1785
https://lemmy.world/u/pogodem0n posted on Feb 20, 2026 18:36

Hi, c/selfhosted! This is my first post on Fediverse and I am glad to be making it here.

I recently got fed up with having to using Tailscale to access my server at home and decided to expose it publicly. A friend recommended segregating the server into a dedicated VLAN. My router’s stock firmware does not allow that, so I flashed OpenWrt on it (I am amazed how simple and easy the process was).

Getting the router to actually assign an IP address to the server was quite a headache (with no prior experience using OpenWrt), but I managed to do it at the end with a help from a tutorial video on YouTube.

Now, everything is working perfectly fine and as I’d expect, except that all requests’ IP addresses are set to the router’s IP address (192.168.3.1), so I am unable to use proper rate limiting and especially fail2ban.

I was hoping someone here would have an experience with this situation and help me.

https://lemmy.world/post/43381650
Reply
$$1803
https://piefed.ca/u/iamthetot posted on Feb 20, 2026 18:52
In reply to: https://lemmy.world/post/43381650

Welcome to Lemmy! Unfortunately I can’t be of help, but if you’ll indulge me, I’m curious why you got “fed up” with using Tailscale.

https://piefed.ca/comment/3582560
Reply
$$1818
https://lemmy.strausfuenf.de/u/strausfuenf posted on Feb 20, 2026 19:13
In reply to: https://lemmy.world/post/43381650

Do you mean requests in the proxy?

https://lemmy.strausfuenf.de/comment/1697
Reply
$$1829
https://lemmy.world/u/pogodem0n posted on Feb 20, 2026 19:24
In reply to: https://lemmy.strausfuenf.de/comment/1697

Yeah, it is the proxy. Same is true for SSH, though.

https://lemmy.world/comment/22255143
Reply
$$1833
https://lemmy.world/u/pogodem0n posted on Feb 20, 2026 19:28
In reply to: https://piefed.ca/comment/3582560

The Android client has a recurring bug where the connection to the Tailnet and the DNS break about half the time when switching between Wi-Fi and cellular networks. Plus, I can’t use it and a VPN at the same time.

I can remedy that by toggling the connection off and on from the notifications panel, but it still keeps breaking with stuff that use a persistent connection, like ntfy and FMD.

https://lemmy.world/comment/22255233
Reply
$$1846
https://lemmy.dbzer0.com/u/superglue posted on Feb 20, 2026 19:52
In reply to: https://lemmy.world/post/43381650

Try experimenting with the masquerade setting on the VLAN its on.

https://lemmy.dbzer0.com/comment/24535322
Reply
$$1849
https://lemmy.decronym.xyz/u/Decronym posted on Feb 20, 2026 20:01
In reply to: https://lemmy.world/post/43381650

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

Fewer Letters More Letters
DNS Domain Name Service/System
SSH Secure Shell for remote terminal access
VPN Virtual Private Network

[Thread #107 for this comm, first seen 20th Feb 2026, 20:01] [FAQ] [Full list] [Contact] [Source code]

https://lemmy.decronym.xyz/comment/12745
Reply
$$1866
https://discuss.tchncs.de/u/PotatoesFall posted on Feb 20, 2026 20:50
In reply to: https://lemmy.world/post/43381650

I’m not really experienced with VLANs but this seems interesting. Is this only for requests from within the network or also for requests coming from outside the network, i.e. from your phone via cellular data or from a VPS?

https://discuss.tchncs.de/comment/24056332
Reply
$$1875
https://lemmy.world/u/talkingpumpkin posted on Feb 20, 2026 21:03
In reply to: https://lemmy.world/post/43381650

Getting the router to actually assign an IP address to the server

You would typically want to use static ip addresses for servers (because if you use DHCP the IP is gonna change sooner or later, and it’s gonna be a pain in the butt).

IIRC dnsmasq is configured to assign IPs from .100 upwards (unless you changed that), so you can use any of the IPs up to .99 without issue (you can also assign a DNS name to the IP, of course).

all requests’ IP addresses are set to the router’s IP address (192.168.3.1), so I am unable to use proper rate limiting and especially fail2ban.

Sounds like you are using masquerade and need DNAT instead. No idea how to configure that in openwrt - sorry.

https://lemmy.world/comment/22256839
Reply
$$1876
https://lemmy.world/u/pogodem0n posted on Feb 20, 2026 21:04
In reply to: https://discuss.tchncs.de/comment/24056332

Both.

https://lemmy.world/comment/22256843
Reply
$$1878
https://lemmy.today/u/tal posted on Feb 20, 2026 21:05
In reply to: https://lemmy.world/post/43381650

except that all requests’ IP addresses are set to the router’s IP address (192.168.3.1), so I am unable to use proper rate limiting and especially fail2ban.

I’d guess that however the network is configured, you have the router NATting traffic going from the LAN to the Internet (typical for a home broadband router) as well as from the home LAN to the server.

That does provide security benefits in that you’ve basically “put the server on the Internet side of things”, and the server can’t just reach into the LAN, same as anything else on the Internet. The NAT table has to have someone on the LAN side opening a connection to establish a new entry.

But…then all of those hosts on the LAN are going to have the same IP address from the server’s standpoint. That’s the experience that hosts on the Internet have towards the same hosts on your LAN.

It sounds like you also want to use DHCP:

Getting the router to actually assign an IP address to the server was quite a headache

I’ve never used VLANs on Linux (or OpenWRT, and don’t know how it interacts with the router’s hardware).

I guess what you want to do is to not NAT traffic going from the LAN (where most of your hardware lives) and the DMZ (where the server lives), but still to disallow the DMZ from communicating with the LAN.

considers

So, I don’t know whether the VLAN stuff is necessary on your hardware to prevent the router hardware from acting like a switch, moving Ethernet broadcast packets directly, without them going to Linux. Might be the case.

I suppose what you might do — from a network standpoint, don’t know off-the-cuff how to do it on OpenWRT, though if you’re just using it as a generic Linux machine, without using any OpenWRT-specific stuff, I’m pretty sure that it’s possible — is to give the OpenWRT machine two non-routable IP addresses, something like:

192.168.1.1 for the LAN

and

192.168.2.1 for the DMZ

The DHCP server serves DHCP responses for the LAN that tell it to use 192.168.1.1 as the default route, and 192.168.2.1 for hosts in the DMZ. So, for example, the server in the DMZ would maybe be assigned 192.168.2.2.

Then it should be possible to have a routing table entry to route 192.168.1.1 to 192.168.2.1 and vice versa, just as as if the two addresses were actually physical routers.

When a LAN host initiates a TCP connection to a DMZ host, it’ll look up its IP address in its routing table, say “hey, that isn’t on the same network as me, send it to the default route”. That’ll go to 192.168.1.1, with a destination address of 192.168.2.2. The OpenWRT box forwards it, doing IP routing, to 192.168.2.1, and then that box says “ah, that’s on my network, send it out the network port with VLAN tag whatever” and the switch fabric is configured to segregate the ports based on VLAN tag, and only sends the packet out the port associated with the DMZ.

The problem is that the reason that you want to use NAT is to disallow incoming connections from the server to the LAN. This will make that go away — the LAN hosts and DMZ hosts will be on separate “networks”, so things like ARP requests and other stuff at the purely-Ethernet level won’t reach each other, but they can freely communicate with each other at the IP level, because the two 192.168.X.1 virtual addresses will forward packets between each other. You’re going to need to firewall off incoming TCP connections (and maybe UDP and ICMP and whatever else you want to block) inbound on the 192.168.1.0/24 network from the 192.168.2.0/24 network. You can probably do that with iptables at the Linux level. I think that all the traffic should be reaching the Linux kernel in this scenario.

If you get that set up, hosts at 192.168.2.2, on the DMZ, should be able to see connections from 192.168.1.2, on the LAN, using its original IP address.

That should work if what you had was a Linux box with two Ethernet cards and the VLAN stuff wasn’t in the picture. I’m not 100% certain that any VLAN switching fabric stuff might muck that up — I’ve only very rarely touched VLANs myself, and never tried to do this. But I can believe that it’d work.

If you do set it up, I’d also fire up tcpdump on the server. If things are working correctly, sudo ping -b 192.168.1.255 on the LAN shouldn’t show up as reaching the server. However, ping 192.168.2.1 should.

https://lemmy.today/comment/22402829
Reply
$$1879
https://discuss.tchncs.de/u/PotatoesFall posted on Feb 20, 2026 21:07
In reply to: https://lemmy.world/comment/22256843

Is it possible that you have something called “masquerading” enabled on the firewall zone that the server is in?

https://discuss.tchncs.de/comment/24056634
Reply
$$1881
https://lemmy.world/u/pogodem0n posted on Feb 20, 2026 21:17
In reply to: https://discuss.tchncs.de/comment/24056634

That was it! I messed around with the port-forward settings with no luck in the past. Disabling the “Masquerade” option in the firewall settings for the server’s VLAN worked. Thanks a bunch.

https://lemmy.world/comment/22257082
Reply
$$1882
https://lemmy.today/u/tal posted on Feb 20, 2026 21:18
In reply to: https://lemmy.world/comment/22256839

You would typically want to use static ip addresses for servers (because if you use DHCP the IP is gonna change sooner or later, and it’s gonna be a pain in the butt).

In this case, he controls the local DHCP server, which is gonna be running on the OpenWRT box, so he can set it to always assign whatever he wants to a given MAC.

https://lemmy.today/comment/22403070
Reply
$$1901
https://lemmy.dbzer0.com/u/mic_check_one_two posted on Feb 20, 2026 21:58
In reply to: https://lemmy.today/comment/22403070

Yeah, this is my preferred way of doing it. That way I always have a nice compiled list of IP addresses, and if I ever need to change any of them, I have them all in a single menu instead of needing to access each device individually.

https://lemmy.dbzer0.com/comment/24537484
Reply
$$1904
https://lemmy.dbzer0.com/u/mic_check_one_two posted on Feb 20, 2026 22:05
In reply to: https://lemmy.world/comment/22255233

Yeah, Tailscale’s “zero-config” idea is great as long as things actually work correctly… But you immediately run into issues when you need to configure things, because Tailscale locks you out of lots of important settings that would otherwise be accessible.

For instance, the WiFi at my job blocks all outbound WireGuard connections. Meaning I can’t connect to my tailnet when I’m at work, unless I tether to my personal cell phone (which has a monthly data cap). Tailscale is built on WireGuard, and WireGuard only. If I could swap it to use OpenVPN or IKEv2 instead, I could bypass the problem entirely. But instead, I’m forced to just run an OpenVPN server at home, and connect using that instead of using Tailscale.

https://lemmy.dbzer0.com/comment/24537584
Reply
$$1987
https://lemmy.world/u/non_burglar posted on Feb 21, 2026 13:30
In reply to: https://lemmy.today/comment/22402829

Wow, there’s a lot going on in there.

https://lemmy.world/comment/22267007
Reply