I’ve been following this community for some time in order to learn about self-hosting and, while I have learnt about a bunch of cool web services to host, I’m still lost on where/how to start. Does anyone have, like, a very beginner guide that is not just “install this distro and click these buttons”? I have an old laptop that runs Arch (btw), but I’m not familiar with networking at all. So anything starting from “you can check your IP address using ip a” would be appreciated.

More specifically, I have a domain that I want to point to an old laptop of mine (I intend to switch to a VPS if/when I feel like the laptop is starting to lose it). How do I expose my laptop to the internet for this to work (ideally without touching my router, because I’ll be traveling quite a bit with my laptop and don’t mind the occasional downtime). I assume that once I’m able to type my domain name on my mobile and see it open anything from my laptop, I can then setup all the services I want via nginx, but that’s step 2. I tried to follow a few online guides but, like I mentioned, they’re either too simplistic (no I don’t want to move to Ubuntu Server just for this) or too complex (no I don’t know how DHCP works).

Thanks in advance

  • Alami@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    There is this mostly French community (second language English) called yunohost (read y u no host) that provides a selfhosting solution accessible for beginners. They even offer one free domain to familiarise yourself hands on (+letsencrypt certificate). I have been using this for two years and it works well, I ran into issues but learned a lot in the process, community and devs are nice and helpful. Based on debian. https://yunohost.org/#/index_en They package most of the popular applications you’d expect for selfhosting (nextcloud, owncloud, WordPress, drupal and easily a hundred other apps)

  • Shdwdrgn@mander.xyz
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    It sounds like maybe you’re looking for a primer on how networking works across the internet? If so, here’s a few concepts to get you started (yeah unfortunately this huge post is JUST an overview), and note that every one of these services can also be self-hosted if you really want to learn the nuts & bolts…

    DNS is the backbone of everything, it is the service that converts names like “lemmy.world” into an actual IP address. Think of it like the phone book of the internet, so like if you wanted to call your favorite pizza place you would find their name, and that would give you their phone number. Normally any domain that you try to reach has a fixed (or static) IP address which never (or rarely) changes, and when you register your domain you will point it to a DNS server that you have given authoritative access to provide the IP where your server can be found.

    But what if you’re running a small setup at home and you don’t actually have a static IP for your server? Then you look to DDNS (Dynamic DNS) and point your domain’s DNS to them. There are several free ones available online you can use. The idea is you run a script on your server that they provide, and every time your IP from your ISP changes, the script notifies the DDNS service, they update their local DNS records so the next person looking for your domain receives the updated IP. There can be a little delay (up to a few minutes but usually only seconds) in finding the new address when your IP changes, but otherwise it will work very smoothly.

    You mentioned DHCP, so here’s a quick summary of that. Basically you are going to have a small network at your home. Think of your internet router as the front-end, and everything behind it like you computers or mobile devices are going to be on their own little private network. You will typically find they all get an IP address starting with 192.168.* which is one or the reserved spaces which cannot be reached from the internet except by the rules your router allows. This is where DHCP comes in… when you connect a device it sends out a broadcast asking for a local network IP address that it is allowed to use. The DHCP server keeps track of the addresses already in use, and tells your device one that is free. It will also provide a few other local details, like what DNS server to use (so if you run your own you can tell the DHCP service to use your local server instead of talking to your ISP). So like the phone book analogy, your DHCP service tells all of your local devices what phone number they are allowed to use. other Now to put all of this together, you probably have a router from your ISP. That router has been pre-programmed with the DHCP service and what DNS servers to use (which your ISP runs). The router also acts like the phone company switchboard… if it sees traffic between your local devices like a computer trying to reach your web server, it routes those calls accordingly. If you are trying to get to google then the route sends your call to the ISP, whose routers then send your connection to other routers, until it finally reaches google’s servers. Basically each router becomes a stepping stone between your IP address and someone else’s IP address, bringing traffic in both directions.

    OK so now you want to run a web server for your domain. This means that besides getting the DNS routing in place, you also need to tell your router that incoming web traffic needs to be directed to your web server. Now you need to learn port numbers. Web pages traffic on port 80, and SSL pages use port 443. Every type of service has its own port number, so DNS is port 53, ftp is port 21, and so on. Your router will have a feature called port-forwarding. This is used when you always want to send a specific port to a specific device, so you tell it that any incoming traffic on port 80 needs to be sent to the IP address of your web server (don’t worry, this won’t interfere with your own attempts to reach outside websites, it only affects connections that are trying to reach you).

    Now if you’ve followed along you might have realized that even on your local network, DHCP means that your server’s own IP address can change, so how can you port-forward port 80 traffic to your web server all the time? Well you need to set a local static IP on your server. How that is done will be specific to each linux distribution but you can easily find that info online. However you need to know what addresses are safe to use. Log in to your router, and find the DHCP settings. In there you will also see a usable range (such as 192.168.0.100 to 192.168.0.199). You are limited to only changing the last number in that set, and the router itself probably uses something like 192.168.0.1. Each part of an address is a number between 0-255 (but 0 and 255 are reserved, so except in special cases you only want to use the numbers 1-254), so with my example of the address range being used by DHCP, this means that you would be free to use any address ending in 200-254. You could set the static IP of your web server to 192.168.0.200, and then point the port-forwarding to that address.

    Now remember, your local IP address (the 192.168 numbers) are not the same as your external internet address. If you pay your provider for a static internet address, then your router would be programmed with that number, but your web server would still have its local address. Otherwise if you’re using DDNS then you would tell that service the outside IP address that your router was given by your ISP (who coincidentally is running a DHCP that gave your router that address).

    Let me see if I can diagram this… OK so imagine your router has the internet address of 1.2.3.4, your web server has the local address of 192.168.0.200, and someone from the internet who has address 100.1.1.1 is trying to reach you. The path would be something like this:

    100.1.1.1 -> (more routers along the way) -> your ISP -> 1.2.3.4 (router) -> 192.168.0.200 (server)

    They send a request to get a web page from your server, and your server send the page back along the same path.

    Yes there’s a lot to it, but if you break it down one step at a time you can think of each step as an individual router that looks to see if the traffic going to something on the outside or going to something on the inside. Which direction do I need to send this along? And eventually the traffic gets to a local network that says “hey I recognize this address and it needs to go over to this device here.” And the key to all of this routing is DNS which provides hints on where to forward the information to the next router in the path. I can break things down further for you if something isn’t clear but hopefully that gives you a broad overview on how things move around on the internet.

    • Mars2k21@kbin.social
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Honestly one of the most well written posts I’ve read. Thanks a lot, helped me understand all of this networking stuff involved with self-hosting since I literally just bought a PC to function as my home server like 2 days ago.