Build your own StorJ node (5/9) - Configure OS for your SBC

By DanBlock | Tech Projects | 6 Jun 2020


Configure OS for your SBC

Welcome back to this series of articles on how to build your own super efficient StorJ node, the summary of this series can be found here.

This will be a longer article because there is much to cover, I apologise in advance.

It will also be more technical and will require some basic network and Linux knowledge.

If you did read my other articles, in particular the on Armbian OS, you should have the OS on a microSD card installed on your Odroid HC1.

What do you need before we start:

  • An SSH client of your choice. Windows 10, Linux and MacOS have a terminal-like you can use to SSH into a remote system.
  • Your SBC must have the microSD plugged in
  • The microSD must have the latest Armbian OS for Odriod HC1. You can download it from here, use the version on the right hand-side (currently Armbian Buster)
  • The power plugged in and the board has completed boot sequence
  • The dynamic IP assigned from your router to the board. You can find this by logging in your router and check for the wired connected devices.

To SSH to your SBC use the command below (works on MacOS and Linux Terminal):

I assume the IP Address assigned to your board is 192.168.1.10  Please change it with the actual IP once known.

ssh [email protected]

The default password is: 1234

On the first login it prompts you to change this password (US-Keyboard setting). When done, you are asked to create a normal user-account for your everyday tasks. Please complete all and save your information somewhere safe.

Setup Static IP

The very first thing you need to do now is to give your SBC a static IP rather than a dynamic one.

It is highly recommended doing this via your router if it supports reserving an IP to a device. If not, you will have to do it on the SBC on the OS configuration.

We will look at both options below.

Option 1 - Use your router to assign a static IP

You will most likely need the MAC address of the network card in your SBC.

Your router should show the MAC address of all connected devices, you can confirm which is the one of your SBC by SSH to it and running the below command:

ifconfig -a | grep ether (ensure the network cable is connected to the board and it’s blinking before running the command below)

One of these lines will have the 1000 number

Your MAC address will be the series of numbers and letter separated by : in the line where the 1000 number is shown

Example here: 02:42:a0:cf:dc:78

Official instruction on how to do this can be found on the vendor websites. Most common below:

TP-Link Router: https://www.tp-link.com/us/support/faq/182/

NetGear router: https://kb.netgear.com/25722/How-do-I-reserve-an-IP-address-on-my-NETGEAR-router

D-Link: https://eu.dlink.com/uk/en/support/faq/cameras-and-surveillance/mydlink/settings/router/how-do-i-configure-dhcp-reservation-on-my-dir-series-router

Linksys: https://www.linksys.com/us/support-article?articleNum=135673

 

You will need the MAC address that you found above, all router will want this in their own format, some will prefer a . As separator, others will want a - and other nothing.

If we use the MAC address we got from our SBC you will do something like below. They are all the same thing, it just depends what your router preferred format is:

02:42:a0:cf:dc:78

02.42.a0.cf.dc.78

02-42-a0-cf-dc-78

0242a0cfdc78

Option 2 - Set a static IP manually

If reserving an IP on your router is not an option, you will need to do it on your board.

If the IP you SBC got from the router is for example 192.168.1.10, it will mean your router gives IPs from 192.168.1.2 to 192.168.1.254

Understanding Dynamic IP assignment

Every time a new device appears on the network, the router will dynamically assign an IP available in that range from the lowest number to the highest

For example, let’s assume you don’t have any device online on your network, then you turn your pc on.

The PC will get 192.168.1.2

After you turn on your smartphone. And it will get 192.168.1.3 and so on

The IP will be kept for the device for the whole time it’s active. If you turn it off, it will lose the assigned IP and the router will assign a new one the next time the device comes back online

Now let’s assume you turn off your PC so 192.168.1.2 is free to use and you decide to manually assign this IP to your SBC.

This will work fine until you turn on your PC, the router will check available IPs in its database and assign 192.168.1.2 because the router has no knowledge you assigned that IP manually to something else.

This will cause an IP conflict and both your PC and your SBC will start having network issues and will most likely have no network or terrible network performance

With that out of the way, if you must use this method, there are things you could do on your router to safely configure it in a way you can avoid IP conflicts but it will take a long time to explain and you could cause big problem if you don’t do it right.

A safer way to do it is to assume you will never have more than 150 devices active at the same time and therefore you should be able to use 192.168.1.151 on your SBC without too many issues.

Run the Armbian OS config utility using below command

armbian-config

Now navigate the menu as below

Network->IP

Select the first interface in the list

Select Static

Type the static IP you want to use, net mask and Gateway IP (your router)

 

Update Armbian OS

To update your OS to the latest patches and remove unnecessary tools, run the three commands below while logged in on your board as root

apt-get -q -y update && apt-get -q -y upgrade

apt-get -q -y install unattended-upgrades

apt-get -q -y autoclean && apt-get -q -y autoremove

 

Optimise Armbian OS for your SBC

Armbian OS have specific settings that need to be adjusted to get the most our of your board, some are basic like timezone while others are critical like DTP and kernel versions

To make these changes, please follow steps below.

Run the Armbian OS config utility using below command

armbian-config

Now navigate the menu as below

System->Personal->Timezone (Set your timezone here)

System->Personal->Locales (Set your locale here)

System->Personal->Keyboard (Set your keyboard layout here)

System->Personal->Hostname (Set your board hostname here, can be anything but I suggest odriod-hc1)

System->DTB (This will set board specific settings)

Select Odroid HC1/HC2 and press OK

It will ask to reboot, confirm

 

Once rebooted run the Armbian OS config utility again using below command

armbian-config

and navigate the menu as below

System->Other (From here you can select to use latest kernel)

Press “Space” to select “Yes, I understand” and press OK

Select latest “current” version of the linux image for the HC1 board

At the time of writing is the:

linux-image-current-odroidxu4=20.02.1 - 5.4.19-odroidxu4

Select ok to install

This will take some time so don’t worry. Once done, the system will reboot and you will be able to login again

 

Once rebooted run the Armbian OS config utility again using below command

armbian-config

and navigate the menu as below

System->Avahi (This will enable network advertising so you will be able to SSH to your node using the hostname rather than the IP)

Once done you can SSH to your node using <hostname>.local where <hostname> is the name you set before

And last, navigate to

System->Firmware (to update all firmware)

 

Congratulations! Your SBC is now configured with the best settings and updated to latest software versions.

 

Dynamic DNS and Port Forwarding

The last part we need to setup is a way to allow the board to be always reachable from the internet.

To understand the problem you need to know that your home router uses an IP to be reachable from the internet, this IP is assigned by your Internet Service Provider (ISP) and changes regularly depending on network usage. 

The only way other systems in the internet can reliably reach systems in your network is by having a reference that never changes. Imagine your home address changing every day, the post office will never know where to send your letters!

Normally you would achieve this by purchasing a public static IP from your ISP but these are very expensive and normally not provided at all to home users.

Thankfully, there are ways we can do it using external tools that will give us a DNS name associated with our dynamically assigned IP. Other systems in the internet can reach us by using this DNS name that never changes.

You will ask, what happens when the ISP changes my IP? Good question, the way this works is that when your router detect the IP has changed, it will notify the DNS tool on the new IP and your DNS name will be updated to point to the new IP.

Dynamic DNS Service

This service is provided by a lot of internet companies, in our case I recommend using NoIP which is also free and supported by a large number of routers. 

If your router is supported, this will provide the best experience. To check if your router is supported and configure the service go here:

https://www.noip.com/support/knowledgebase/how-to-configure-ddns-in-router/

If your router is NOT supported, you can install an agent on your Armbian OS that will constantly check your public IP and inform. the service once it changes

To install the agent, SSH to your SBC as root and run the commands below

cd /usr/local/src/

wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

tar xf noip-duc-linux.tar.gz

cd noip-2.1.9-1/

make install

 

You’ll then be prompted to log in with your NoIP account username and password.

NB: If you get “make not found” or “missing gcc” then you don’t have the gcc compiler tools installed. Install the gcc compiler tools to proceed.

Now issue this command 

/usr/local/bin/noip2 -C

 

You’ll then be prompted for your NoIP username and password, as well as the hostnames you wish to update.

Lastly, run this command

/usr/local/bin/noip2

 

Port Forwarding

The last piece of the puzzle is to tell your router to send all requests to your SBC when they coming from the internet and directed to a specific port.

This is because StorJ service in the internet will try to connect to your node on port 28967, your router will receive this request but doesn;t know what to do with it and will discard it.

You need to tell your router that if a request is coming on that port it is meant to be sent to your SBC who will know what to do with it.

To do this just follow the instruction for your router, it should be straightforward and you only need to provide the static IP of your SBC that you configured at the beginning of this page.

 

I know the article can prove challenging for some and I'm happy to answer any question you may have in the comments!

How do you rate this article?

32



Tech Projects
Tech Projects

Articles on technology projects

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.