Are you exposing any ports on your home server?

ffhein@lemmy.world to Selfhosted@lemmy.world – 62 points –

Maybe I'm using the wrong terms, but what I'm wondering is if people are running services at home that they've made accessible from the internet. I.e. not open to the public, only so that they can use their own services from anywhere.

I'm paranoid a f when it comes to our home server, and even as a fairly experienced Linux user and programmer I don't trust myself when it comes to computer security. However, it would be very convenient if my wife and I could access our self-hosted services when away from home. Or perhaps even make an album public and share a link with a few friends (e.g. Nextcloud, but I haven't set that up yet).

Currently all our services run in docker containers, with separate user accounts, but I wouldn't trust that to be 100% safe. Is there some kind of idiot proof way to expose one of the services to the internet without risking the integrity of the whole server in case it somehow gets compromised?

How are the rest of you reasoning about security? Renting a VPS for anything exposed? Using some kind of VPN to connect your phones to home network? Would you trust something like Nextcloud over HTTPS to never get hacked?

133

I think many of us are using reverse proxies, and opening port 443 (https) and maybe port 80 (http).

Port forwarding can be a recipe for disaster. I'd much rather make use of reverse proxying.

For lots of things I self host that I wanna expose, I’ll just open a random port like 6952 and then reverse proxy w/ nginx on my web server. Not sure how secure it is, but it works

Ports are probed and scanned constantly so a random port doesn’t make so much difference. I would use a strict firewall with the server IP whitelisted.

Can they see what you are hosting on that port, though? Like say I want to open ssh to my server from the internet (I don't do this and I wouldn't unless it was temporary), but I don't want to open it on port 22 because that's too obvious. Are there bots that just try every protocol until they find one that your server responds to? Or is there a way to dig up information on what is being exposed behind that port?

Ever since I moved to a ridiculously high port I haven't had any access attempts on my server. 6952 won't do shit, but if you're between 40000 and 65000 you probably won't get anything.

That’s security through obscurity and one should never rely on this strategy alone

If it's your only form of security then it's bad. But if it's on combination with other measures then it's a good thing.

I wouldn't let anyone who hits my ip/port directly into my openvpn. But not having china and russia bomboarding me with requests is nice.

@housepanther @effingjoe Unless you're running a router/firewall on the edge that can act as a reverse proxy, you kind of need to port forward to a reverse proxy if you're behind NAT.

You could use a VPS as a proxy and set up a VPN tunnel between the home server and the VPS to avoid port forwarding altogether. I do this for my mastodon and lemmy instances. My home server is of course behind NAT but there's no need for any kind of port forwarding. I should know because I have none configured.

Unless you need to share/provide services for a public, then you shouldn't be setting up reverse proxies or cloudflare tunnels in my opinion. All you need is WireGuard for you and the handful of users that might be using it.

I have two ports open for:

  1. WireGuard

  2. SSH Tunnel

Both of these services will only accept key based authentication.

WireGuard is the main way that my wife and me access the services away from home. When our phones disconnect from our home's SSID, Tasker automatically connects to the WireGuard tunnel so we never lose access to services.

The SSH tunnel is just a fallback in case I get behind a firewall that might be doing DPI and blocking VPN traffic. The SSH tunnel operates on 443 to hopefully appear to be SSL traffic and allowed through. I've used it a very limited amount of times to get out from strict corporate firewalls.

I was able to reduce that to just SSH by having my Wireguard host on a VPS and connecting out from home. Running SSH on 443 is a neat idea.

Running ssh on 443 doesn't do anything unfortunately. A proper port scan will still detect such a common protocol.

It's more about gaining access from inside a network that doesn't allow outbound on 22. For the web to work it would need 443 so connecting out on 443 might work

Sure, just don't mistake port switching for actual security.

I think you may be still missing the point because it was never implied that the port change is for security; the security is in disabling password authentication and only accepting key based authentication. The reason I put it on 443 is because it is a port that is usually allowed by firewalls and doesn't get as much attention. So if I am on a network that is blocking access for standard VPN or SSH ports then it might just be enough for me to bypass it. And it's traffic on a port that is going to see a lot of other encrypted traffic going across it, so it looks more natural then just popping some other random ports that could potentially raise an alarm.

I'm not missing any point. It should be clear to people who don't understand security that running a protocol on a different port doesn't mean shit for safety. "Because it doesn't get as much attention" wouldn't mean anything to any enterprise firewall the moment it's not an http header.

You are talking about security when that is not the purpose of it. So yes, you are off on a tangent and missing the point of it.

It should be clear to people who don’t understand security that running a protocol on a different port doesn’t mean shit for safety.

It is clear, it's clear to everyone, so why did you randomly interject irrelevant information? Because you incorrectly assumed someone thought it had to do with security... but no one here thought it had anything to do with security. Everyone understood it but for you, and you were corrected not only by me but the other person.

Because it doesn’t get as much attention” wouldn’t mean anything to any enterprise firewall the moment it’s not an http header.

As I've said, I've used it a few times to escape firewalls... it works. Will it always work? No, I never made the claim this will bypass all firewalls... the strictest of firewalls will block it, but there are other ways around those firewalls. E.g. proxytunnel, stunnel4

Absolutely. Though putting it on 443, which is regularly port scanned as well, is the opposite of security through obscurity.

Why not use Wireguard from your phones all the time, even at home? Just performance?

It would be extra overhead for no reason. Why keep it on when Tasker automates it?

I don't know about your particular use case, but I've found that some apps experience problems when the IP address of a resource they're using changes out from under them. Like either they experience temporary connectivity issues during the transition or even just stop being able to reach the resource until restarted. However if your setup is working for you, that's great!

I'm confused why the IP address of a resource is changing for you when you're moving in/out of the wireguard tunnel? In my setup the LAN IP addresses always stay the same whether I'm on the local network or accessing remotely, It's just the route to them that changes (over a different ethernet adapter). Perhaps that's what you meant, or there's some crazy configs out there I'm unaware of.

I fully admit I may be doing this wrong. But in order to connect to a server over Wireguard I'm connecting to it over its Wireguard IP address. (And if I'm not connecting to it over Wireguard I don't connect to it over a Wireguard IP address.) It's relevant to note that I'm not using Wireguard as a traditional VPN where all traffic bound for the internet is tunneled over Wireguard. Instead, I'm using it strictly for point-to-point tunneling from a client to one of my servers. In other words, my default routes don't go to Wireguard. Maybe that's the difference here?

Yeah, I haven't had any problems with it, what apps have been an issue for you?

The app that I use the most during that transitional period would be Ultrasonic which would be streaming music from the Airsonic service as I get in my vehicle and drive away or arrive back home. But even that flawlessly transitions without skipping a beat since it is set to cache songs.

The app that comes to mind as having problems with changing IPs is the Home Assistant app. It would simply lose connectivity when the IP changed and never do another DNS lookup to connect again.. I always had to restart it. The "solution" for me was not to change IPs and just leave Wireguard on. It's cool that Ultrasonic handles it though.

Interesting, yeah, maybe report it as an issue on github, I use a browser link to my dashboard for Home Assistant instead of the app so it hasn't happened to me. I almost installed it the other day to get presence detection but decided on another way.

I've had 22, 80, & 443 open for literal decades. Key auth only on ssh. 80 & 443 rev proxy to inside web services I want to expose only. Also host game servers as needed.

Keep your stuff up to date and follow best practices for securing it. Use things like crowdstrike. If you can segment your network, go ahead.

Unless you have a target on your head your main concern is going to be scripts looking for vulnerabilities.

I am not exposing any ports online. I do not trust myself

Instead, I am using Tailscale (Wireguard)

I've got a very similar setup now. Only recently adopted tailscale and was previously port tunnelling over SSH to access anything on the local network. SSH is still open, and am just waiting a bit to see if theres any cases where I need it before closing that out too.

Short story: If you don't need stuff open to the general public, just having Tailscale will probably cover you.

Ya my paranoia only allows me to expose Wireguard to access everything. I sleep better at night knowing that's the only thing exposed. Too many instances of major companies getting hacked who have dedicated security teams to manage that. I am one person, learning to manage my own stuff in my free time.

I open 443 and 80 on my router and forward it to a reverse proxy.

I have a couple of service that are exposed but most of them make sense only when I'm home so I whitelist private IP address on my reverse proxy.

If you do.your basic security such as updating your servers and services and not having dumb password, you shouldn't be afraid. Think about it, all of the services that you use is exposed on the internet. I did work for big company and they don't do much more than what you would probably do, except maybe having some automated monitoring that flag weird stuff. But hey, aside from bots, I don't think Russian hackers are interested in your stuff. Stay low profile with your exposed things and it's gonna be alright. Make sure you backup.

Run your own vpn, and only allow access to your services remotely if they are coming through that vpn.

Now you've shifted some of the security over to how secure your vpn server's authentication is.

I’ve got a few layers of security for my homelab setup that make me feel pretty comfortable against random attacks.

Cloudflare is used to manage my domains and act as an external proxy to obscure my IP address, I’ve only forwarded ports 80 and 443 to Traefik my containerized reverse proxy, Authelia to add 2FA to services that I feel should have extra protection and my homelab nodes are on a separate vlan that is configured to drop all attempts to initiate communication outside of that vlan. I also use the ubiquity intrusion detection and prevention features on my firewall to attempt to stop any know malicious activity.

A majority of these configurations are overkill for a homelab, but were fun to implement. If you use a reverse proxy and keep your software up to date you will likely be fine unless you are specifically targeted by skilled hackers. Any random scans, or shotgun style attacks tend to target unpatched vulnerabilities.

https, wireguard and mumble.

Just set up shodan monitoring, use burpsuite or owasp zap, and check your pcap files for accidental plaintext.

Also ssllabs has a nice website checker.

And get a NGFW

Everything except https and wireguard went above my head. Do you have some sort of guide/writeup that you can point to for integrating all this?

Shodan is a internet scanning website, it can monitor your IP for new ports open and some basic vulnerability stuff.

Burpsuite is a tool to capture network traffic, they are saying they use it to confirm all their services use end to end encryption for communication.

NGFW is next gen firewall and it's just a firewall that's able to do more than your basic in/out rules.

Run a WireGuard VPN on your server and only forward its port (only UDP is needed) to your server.

Exposed is the right term. Other than my Wireguard VPN port, everything I have exposed is HTTPS behind Authelia MFA and SWAG.

I'm tempted to switch Wireguard for Tailscale, as the level of logging with WG has always bothered me. Maybe one day.

I did for a while, but it never felt right.

I’m also lazy a f, so I purchased a new router that comes with WireGuard VPN and that works well enough with our iPhones.

I have https open along with a non-standard port for ssh. Just for fun, I have the standard ssh port open, but redirecting to a Raspberry Pi running a honeypot. It's fun to mess with foreign bots trying to access my network.

Do you see much activity there?

I know that they say that security through obscurity doesn’t work, but to me (a novice) it sounds like a good idea to route the default port to a dummy server.

I do see a decent amount of activity on it. Full disclaimer, I am not a security expert. I know just enough to be dangerous. But, I see at least a few connection attempts from different IPs about every day. The top 3 countries of origin are China, Russia, and Brazil (based on the reverse DNS, but it's possible some are using VPNs to hide their origin). My impression is they're all bots that just go through a list of IP addresses, attempting to connect to the standard ssh port, then guessing the username and password. What I've found is they usually go through a list of likely ssh ports until one of them connects. Having the default port open to only the honeypot means they usually establish the connection, then leave it at that, so my real ssh port never gets hit. I kinda think of it like scambaiting, where I'm just wasting time they might otherwise spend trying to break into someone else's real ssh server.

I have ports open for Wireguard and Plex. So far, no issues that I’m aware of. Time will tell

I only have my (non default) ssh port exposed. I just use an ssh tunnel to access all my services. I don't know if this is a good idea or not, but it works for me.

Security through obfuscation is never a good idea. Best practices for exposing ssh (iirc):

  • disable root login (or at least over ssh)
  • disable password login over ssh, use key pairs instead
  • use fail2ban to prevent brute forcing
  • install security updates frequently

All of those are pretty easy to do, and after that you're in a really good place.

I don't see a problem with ssh tunneling to access services, as long as the ssh server is secured correctly

I should install fail2ban. I already have everything else covered. I've only heard of fail2ban, not very familiar with it. Is it necessary if password login is disabled? Can you brute force ssh keys? I really appreciate your advice.

I definitely recommend you do your own research into this. Brute forcing ssh keys should be practically impossible. Is it necessary to install fail2ban with password login disabled? Not sure, I'm of the opinion that it won't hurt, just one more line of defense. It's pretty easy to setup.

ssh to a few specific ip ranges, WireGuard to the world on a port I randomly picked

Check out tail scale. It's wire guard made easy. I expose http services to the public Internet, and have all my devices on the same network so I can access local services without exposing them to the public Internet.

I'm hosting an email server on a VPS that has fail2ban in it. A lot of ports are open but only wireguard and knockd are listening.

For remote server management, I would use wireguard for regular ssh access, but when I need to configure the wireguard I can just disable/reenable the wireguard-only ssh firewall rule using port knocking, there is also the option of using the serial console on the VPS web ui but it is slower.

Honestly, I'm not sure myself if my public facing services face a DoS attack. Well, there's always an option of using Cloudflare. With that being said though, I think in your case you should just use a free "VPN" like Tailscale or ZeroTier.

Can you eli5 both of those? Tailscale and zerotier...

I am unsure if I can ELI5 those without also ELI5-ing about Computer Network, VPN and Firewall.

They are VPNs. Like a regular network, they connect your devices through their network. They may put Firewall rules to allow you to talk to X networks (any specified networks). That also means the VPN may not allow you to connect to the internet through their network. Now the difference between ZeroTier and Tailscale and other VPNs for accessing the internet is that ZeroTier and Tailscale only permit your traffic to your other devices that are bound to your account and not to the internet (your other internet data won't go through zerotier/tailscale). This configuration is great because you have a virtual and secluded network that you can connect to from anywhere via the internet using ZeroTier/Tailscale networks (with your virtually local IP on ZeroTier/Tailscale).

I used to, but then switched to Cloudflare tunnels and I sleep much better now.

For services that need to be public facing (Mastodon, Lemmy, Gitea...) I'm renting a VPS. Services that are only for personal use run on my home server and are only accessible through Wireguard, with the VPS acting as a "bridge" whenever I'm outside of my home network.

The only port I open is for wireguard. That way I can access all services on my LAN. Wireguard is also very secure and requires keys based authentication so is hard to brute. It also allows me to secure myself if I ever need to join WiFi or an untrusted network

Have a look in to Twingate, that should do exactly what you need.

Openvpn to connect to the network, 80 and 443 for static websites, that's it.

Email gets delivered by a VPS via a different port, ssh acces via vps as well. No initial connections from an ip not from the my country as well.

I don't technically open any ports to the public. I have a site-to-site wireguard tunnel to a hosted server. The hosted server is running a hypervisor with two virtual switches. One switch is my external switch and only my Wireguard server is using it. The other is an internal switch where I place other VMs for separate things. A container host, a terminal server with xrdp, a monitoring server with netdata, stuff like that. All technically, but unnecessarily, accessed through nginx proxy manager.

Because it's site2site with my home equipment on the Wireguard server, i can still connect to my home network where i host a number of separate services like HomeAssistant from outside the home network.

I don't use tailscale, but Wireguard vanilla is super easy to work with. I also have fail2ban pretty much everywhere I can install it because it takes up practically zero resources.

None. If anything, I'd probably set up a VPN. But there's nothing so deathly important on my home network that I would need it while away from home. If I wanted to expose services, I'd use a reverse proxy and increase separation between services.

I'm somewhat like you, in that I recognize I'm not a network guru. My home server with containers, as well as a few other devices are blacklisted from accessing the internet at my router. When i have needed outside access I have one machine with wireguard and some ip forwarding/masqurade etc so I have one connection in but can see the LAN for logging into stuff "locally". The only pain is non internet access devices losing sync with a time server.

I'll put a recommendation out for if you're going to open ports: use abnormal ports. Someone is likely to try to hit your port 22 for ssh, but not your port 49231.

Edit: It's definitely some security by obscurity. Still use a strong password or keys.

I'd if I could, but CGNAT.

This year I started using DynDNS with only my IPv6 address since IPv4 is behind CGNAT and it actually works quite well nowadays

What do you mean works? Like you could access from everywhere some services like Plex or Nextcloud?

yes just like with a static IPv4

Ok, I'm not sure of how exactly this works, but I'm gonna check it out since I have IPv6 addresses.

Just to be clear, even from IPv4 only can access my exposed services?

If you expose ports on IPv4 or IPv6 (port forwarding) anyone can access the service behind these ports if they know your address but so do you too

I run a few services that require ports to be open. Everything that can go behind a reverse proxy does so. But there's some that can't and that's OK.

I use Remote Desktop, BitTorrent, and play games, so I need some things open for that. I used to be super paranoid about hackers and viruses and shit like that, but it's not like those things are looking for regular, everyday users and even if they did get in my system, I don't keep anything important on my computer so I can just wipe it all out and reinstall everything.

80, 443 for HTTP/S, and 587 for a VPN service. Reason being that I travel frequently, and often have to connect through a bunch of different networks, Airport WiFi, mobile roaming, hotel WiFi, etc. and you never know the kinds of network restrictions they impose on their pipes.

80 and 443 is least likely to be dropped, while 587 is a common SMTP port that could make it through most networks.