Posts Lab Setup on Raspberry Pi / VM
Post
Cancel

Lab Setup on Raspberry Pi / VM

Initial Ubuntu Server Setup

Hello and welcome to this segment where i will be taking you through some of the best self hosted applications you can run in your home lab on your RaspberryPi or an Ubuntu Server. In this case i will be using:

If you choose to vitualize your Ubuntu server on VirtualBox or Vmware:

Lets get started… 😎🤏🏼

It should take a minute to download the iso file if you are using fast internet

image

Download and install the pi imager, launch it and follow this steps.

  1. Plug your memory card to a mem card reader
  2. Choose OS

image

  1. Select “Use Custom” and choose the .iso file you downloaded.

image

  1. Choose Storage and select the Memory card

image

  1. Select Write and grab yourself a cup of coffee before the installation completes. ☕

image

In less than 2 minutes, the process should be done.

image

Configuring Wireless Adapter (Method 1)

Close the raspberry pi imager and go to the root of the memory card on the file explorer.

Locate a file called network-config and open it with any text editor. It should look something of the sort.

image

image

For now, i will show you how to configure your wireless adapter if you are planning on using it.

  1. Uncomment the wifi section as shown below.
  2. Modify the highlighted section as shown. Add your Home Router’s name and Password.

NB: They both need to be inside " "

image

  1. You can delete the other section or let it remain as comments. I.e

image

With that done, we should be able to use Wi-Fi without needing to connect an ethernet cable. But we also need to know our username. In this case, the ISO file i downloaded is already pre-configured with a user called ubuntu. How do i know that?🤔 Still in the root directory of the memory card, locate user-data file. you need to ensure this two options are set to true.

image

image

As you can see, we have a user called ubuntu and we should change the password on first boot as the default is set to ubuntu. ssh_pwauth: true simply means that we can be able to authenticate using passwords in ssh sessions.

Eject the SD card and plug it in your Raspberry PI and start it. Since we are doing a headless configuration, we are going to ssh into the server using MobaXterm . But wait, we need an Ip Address for this server. You can log into your home router and get the IP address or you can do a quick nmap scan on your network to determine what IP’s have been assigned to your Pi. In my case, i got 192.168.1.19 & 192.168.1.20

A headless server is a computer without a monitor, keyboard, mouse, or other peripherals.Headless computers are normally controlled over the network.

image

You will get a prompt, asking you to change your password.

image

Once changed, we can log back in with the new password.

image

Configuring Static IP

Next thing we need to do is configure a static IP address on interface eth0. Since this server uses netplan as its default network management tool, we can get the configuration file in /etc/netplan.

It is advisable to create a backup copy of the configuration file. Incase you make any mistakes, you can always role back to your backup file.

In my case, the config file is named 50-cloud-init.yaml. If you are following along on a VM, you are likely to get your config file named 00-installer-config.yaml. Simply modify the ethernets section and ignore Wifi.

Please note: if you are using a linux server on VM, your interface name may not be eth0, most likely enp0s3. take note and work with that.

We could have configured the ethernet settings earlier in the network-config file but i wanted to show you two methods which you can use.

image

Modify the config file with the following lines as is. I’ve made it easier for you to avoid indentation issues. 😉

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]
  wifis:
    wlan0:
      access-points:
        "OSTE VLAN":
          password: "@oste1234"
      dhcp4: true
      optional: true

You then need to run the following command for changes to apply.

sudo netplan apply

This command parses and applies the configuration to the system. Configuration written to disk under /etc/netplan/ will persist between reboots.

If you want to know more about netplan, feel free to read their official documentation

If we now check our IP address, eth0 has a static IP of 192.168.1.100

image

Configuring Hostname

To check your hostname, simply run hostname. To modify the existing hostname, edit /etc/hostname and reboot the system for changes to take place.

1
2
3
4
5
6
7
8
root@ubuntu:/etc/netplan# hostname
ubuntu
root@ubuntu:/etc/netplan# nano /etc/hostname

//reboot system

root@oste:/home/ubuntu# hostname
oste.com

We then need to add this hostname to the hosts file located in /etc/hosts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
root@ubuntu:/etc/netplan# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
root@ubuntu:/etc/netplan# nano /etc/hosts
root@ubuntu:/etc/netplan# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 oste.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

One final step is to add our server’s IP and hostname to our windws hosts file which is located in C:\Windows\System32\drivers\etc. You need administrative privilege to modify the hostfile.

image

Installing Docker

In my Docker segment, ‘Docker Installation’ , i’ve covered how to install docker step-by-step. Feel free to check it out.


Congrats on reaching this far, we have successfully prepared our homelab envirnment. 🥳 Hope this article helped you in one way or another. So what next? 🤔 We have docker installed, right? I am going to take you through the first app/solution that we’ll be using to manage, create , monitor and deploy our apps, this is Portainer.

Stay tuned and thanks for following till this point. Keep safe and share the article if you found it helpful. 😁

This post is licensed under CC BY 4.0 by the author.