DEV Community

Cover image for Setting up a low-cost server
Graham Trott
Graham Trott

Posted on

Setting up a low-cost server

This article is really about choosing an alternative to a Raspberry Pi and using Network Manager to set up wifi on a headless install, but I couldn't get all that into the title. In fact, networking causes more headaches than pretty well anything else so I think the title is actually quite useful, as once that part is done the rest is plain sailing.

For several years the Raspberry Pi has been the preferred choice for small servers, as well as for a host of hobbyist projects. It has decent performance, small size, an attractive price and is well supported by both official and community help channels.

However, the recent chip shortages have hit availability and as a result the price has multiplied several times. At $25 it's excellent value; at $150, meh. So many people have been looking for decent alternatives.

There are many rivals to the RPi, but none enjoy anything like the same breadth of support. There is a distinct lack of good articles out there on how to set up one of these alternatives, so here goes.

The Orange Pi Zero 2 is equivalent in performance to a Pi Model 3, if not slightly better. It's considerably smaller and has everything needed for duty as a small webserver. It's a 4-core, 64-bit model with 1GB of RAM, an RJ-45 Ethernet port, wifi, an SD socket, a single USB port, a micro-HDMI port and a USB-C power socket. And it's available at a very attractive price from Ali Express. I chose a package that bundles the computer with a rather neat transparent case, fired off an order for two and they arrived in the UK in a couple of weeks.

So, now being the proud owner of a pair of rather dinky little computers, the big challenge is what software to run on them. There are a selection of alternatives, notably Armbian, Debian and Ubuntu. I've tried all three and my preference is for Debian.

Debian is available via the Orange Pi website. I choose the bullseye server version since I have little need for a desktop; my application is a local controller for smart radiator valves. I flash a 16GB SD card using Balena Etcher, which takes a couple minutes, then put the card into the OPi, connect an Ethernet cable to my router and power up. A red light comes on right away and few seconds later it goes out and a green one appears. After a minute or two the device is visible on my router's connected devices screen, and a short while after that the SSH server is ready to go. So I log in as root with the password orangepi.

The big job is to set up wifi because I don't want to be tethered to the router all the time. A Google search for help on setting up wifi on Linux turns up a good number of pages, but... nearly all of them are out of date. Since they were written there have been some big happenings in the way networking is managed. You can wave goodbye to dhcpcd, networks/interfaces, ifconfig, ifup and ifdown, because they're all history!

The new kid on the block is Network Manager, a superbly-crafted toolkit that sweeps away all the clutter and makes setting up networking a breeze, just as it ought to be. It's included in new OS builds and specifically in Debian bullseye for the Orange Pi Zero 2.

I'm going to add wifi to my OPi and give it a static IP address. To do this I run the strangely-named nmtui (could that be Network Manager Text UI?) and the user interface pops up:

Screen 1

I move the highlight to Activate a connection, find my own router and click Activate:

Screen 2

I have to give the network password:

Screen 3

which shows the connection as Activated.

Screen 4

I click Back to return to the home screen, then Edit a connection and select the connection I just activated:

Screen 5

I click Edit and the main editing screen appears:

Screen 6

I move down to IPv4 CONFIGURATION and click Automatic to change it to Manual:

Screen 7

then I fill in all the relevant fields. The result looks like this:

Screen 8

Then I go to the bottom of the form, click OK to return to the previous screen, Back to return to the home screen and Activate a connection. I move to my chosen connection and click Deactivate. Then I select it again and click Activate. Finally, I back out of nmtui and close my ssh session by typing exit.

Now I can ssh back in again, either at the previous address using Ethernet or at the new one (192.168.0.95 in my example) using wifi. As well as root, Debian also sets up an orangepi user account, also with the same orangepi password. Now I can disconnect the Ethernet cable and use just wifi. From here on, things depend on the application. The hardest part is in getting networking to work, and the creators of Network Manager have done a superb job that takes away all the frustration of setting up wifi on a Linux headless system.

Top comments (3)

Collapse
 
andypiper profile image
Andy Piper

Useful post! I noticed that the latest Raspberry Pi OS now has an option to enable NetworkManager as well (they were on dhcpd for the longest time). Another thing that is great about NetworkManager and the Debian packaging is that you can straightforwardly add support for VPN connections, for example, there's a plugin that enables OpenVPN support.

Off to AliExpress to find an OrangePi...

Collapse
 
corentinbettiol profile image
Corentin Bettiol

I just followed this article's advice in 2017 and the small dell optiplex fx160 is still the webserver I use for my personal website and a few other websites :)

Collapse
 
whjte profile image
John Snow

great to read articles like this