What is this?
This started out as a learning adventure to see whether it’s possible to turn an old laptop into a Nextcloud container using Podman (instead of Docker) on Ubuntu. Spoiler alert: It is! However, this particular post I have decided to remove the Nextcloud part and just focus on the server setup part. More details about Nextcloud in the Farewell section at bottom.
Why is this?
The idea was that if it works it would be quite a portable way to roll out such a system on an piece of hardware as you move from A to B or needs change. “More portable” is my thinking…
Get Caught Up
For now I assume you have ubuntu 24+ installed on the server itself. I won’t be going into any detail on the actual setup / install of ubuntu server as there is lots of information out there on that.
Let’s go.
Step 1: Do the DNS
In this case, since it’s not for an email server, we can use a residential ISP. Port 25 is likely not required. As such, in this case, Duckdns.org should work just fine.
By the way, if you try to do the crontab -e part of the Duck tutorial and you get the sudo: crontab: command not found message it’s because… wild as it seems… cron isn’t installed. Why? How could cron not be installed on default ubuntu server?… anyways, just sudo apt install cron and done….
Good news: I ended up spending boatloads of time pushing the boundaries with DuckDNS and found out that indeed it does work for this application. Here is a dedicated duckDNS post you should read on the topic before going too far if you are going to try to do this instead of a normal purchased domain (much easier).
Step 2: Do the Static IP Address on the Server
If you end up headless like me, you might need to set a static IP on your network to assure it’s easy enough for you to locate and ssh into. Of course duckDNS can make this easier (see section above) once it’s working. Good thing is you pretty much just need to open a file, edit it, and slap it in… I guess that’s what our handy GUI has been doing for years… anyways here we go:
2a. Find and Prep the Netplan Config File
Find out what your network file thing is called on your particular server as it might vary with this command: ls /etc/netplan/ Mine was called 50-cloud-init.yaml but yours might be something different but should be a .yaml file.
TIP 1: If yours has ‘cloud’ in the file name like mine above, you have to (apparently) create a file, then disable something inside the file, and then continue. Thankfully there is one single command which does both as follows:
sudo bash -c "echo 'network: {config: disabled}' > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg"
2b. Edit and Customize the Netplan Config File
Open / edit the yaml file swapping out your filename where mine is accordingly:nano /etc/netplan/50-cloud-init.yaml
In my case, when I edited my file it looked something like this:
network:
version: 2
ethernets:
eth0:
dhcp4: true
Now I will paste the end result that ultimately worked well for me, so you can create yours, but with your specific deets, which I will briefly cover. I will start by simply giving you the final config that worked for me and why it worked:
network:
version: 2
ethernets:
eth0:
dhcp4: false
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
If you need wifi connection to your device, you’ll have to edit and add on something like this at the bottom in addition, and adjust it accordingly:
wifis:
wlan0:
dhcp4: false
addresses:
- 192.168.1.100/24
access-points:
"Your-WiFi-SSID":
password: "Your-WiFi-Password"
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
(Disclaimer: I did not test/try this wifi config myself but this is the standard setup I found)
Here are the lines you need to adjust in your file:
- eth0: this needs to match your device. By running the following command, you can know for sure:
ip link show - dhcp4: change to ‘false’ from ‘true’ as default is ‘true’
- addresses: 192.168.1.100/24 change the 192.168.1.100 part to the desired IP address of your machine and leave the /24 part
- via: 192.168.1.1 change the via: 192.168.1.1 to your router/gateway IP address
TIP 1: Wrong indentation or things like that can mess it up. Try your yaml in this tool first if you aren’t confident.
TIP 2: If you are trying to do this remotely and don’t know your default gateway, you can run this command after you have ssh’d into the machine and get it: ip route | grep default
Save your changes.
2c. Try / Test Netplan File
With this command: sudo netplan try
TIP: Seriously. I messed up my connections quite badly by doing step 2d (below) before ‘trying’ with step 2c here. Do the try. If you want a memorable jingle for the rule, this rhymes: “Try before Apply”.
2d. Commit to your Netplan Config File.
If happy and no ‘depreciated’ messages, apply your new settings with command: sudo netplan apply
Note: It kicked me out of ssh (no surprise) when I ran this and then I wasn’t able to log back in… so there might be a better way – such as logging in on the physical machine (see note 1 above)
2e. Test to see if your Static IP Stuck
Test to see if it worked with ifconfig to see your new IP. Might need to install net-tools first if you don’t have it, or use another command.
TIP 1: This is a reminder of a tip way above in case you missed it and you messed up your connection somehow: Need to know your interface name because maybe you bunged it up like I did and no IP address showing. Try ip link show and voila…
3. Do the Static IP Address on the Router
Reminder that now you have a static IP it’s a good idea to reserve that in your router and make sure that port 22 is open so that you can always SSH into it from remote, if you need to. Otherwise, I suppose you could stop with just reserving it and skip the port 22 opening. Up to you.
Bonus Idea: If you wish to change your ssh port to a non-standard port like 24 to give the black hatters something to talk about at the water cooler, here is how you do that:
- edit the ssh config file:
sudo nano /etc/ssh/sshd_config - Uncomment the ‘#Port 22’ line and change to your favourite port
- Make sure it’s between 1024 to 65535 to avoid conflicts with standard services
- Restart SSH:
systemctl restart ssh - Remember you made this change or you’ll punch yourself for no reason many times in the future when you can’t connect…
Note: It seems like this change doesn’t happen immediately after logging out and maybe the session stays around on port 22 for a while…
Bonus note: How to find your public IP address from within your headless router? Try this bad boy: curl -L -4 ifconfig.me
4. Open ports on the server
This one I missed and it made some pain for me so don’t forget to open up the ports you need on your server first before thinking you can connect through them since they are closed by default.
sudo ufw allow 80 && \
sudo ufw allow 443
Confirm things are open by using a tool like this and also you can even plug in the domain / duckdns address instead of the IP address to confirm that part is working and open. Ports open and accessible? Continue!
5. Installing Podman on Ubuntu Server
Now that your Server is confirmed up and accessible, let’s start the Podman Setup
5a. Setup Unprivileged Port 80
- Open this for editing:
sudo nano /etc/sysctl.d/99-sysctl.conf(may have different final file name on your version?) - Paste this in at the bottom of file:
net.ipv4.ip_unprivileged_port_start=80 - Control x, yes, enter, bye-bye to save changes and exit editor…
- Restart to apply changes:
sudo sysctl -p(you should see your change echoed back in terminal)
5b. Install the Man of Pod
- Install Podman:
sudo apt install podman - Install podman-compose:
sudo apt install podman-compose(so you can run your startup file)
6. Farewells
Originally I had attempted to make this post to include a Nextcloud setup, but it got really long and was a long journey on its own. I will hopefully remember to post the specific links here in this section for the journey for both Nextcloud and n8n so you could even set those up using that. If I forget, you might still be able to search those in the wayneoutthere.com search field.