⚙️

How to run free5GC on Incus (2of2)

2025/01/02に公開

Abstract

List of documents:
How to run free5GC on Incus (1of2): free5GC VM preparation on Incus
How to run free5GC on Incus (2of2): free5GC Installation on Incus

  • This document is the 2nd part of "free5GC on Incuss".
  • This 2nd part describes steps to build and install free5GC on ubuntu-free5gc VM which was prepared in the 1st part. Note that almost all steps follow ones of Ref1.
  • Also, it describes the installation of UERANSIM on ubuntu-ueransim VM which was prepared in the 1st part.
  • Finally you can perform UERANSIM testing against free5GC.

Ref1: https://free5gc.org/guide/3-install-free5gc/

Install free5GC on VM (ubuntu-free5gc)

A Prerequisites

Enter the VM.

incus exec ubuntu-free5gc -- bash

A.1 Confirm Linux Kernel Version

Confirm the linux kernel version.
NOTE: The version must be 5.4.x as underlined in Ref1.

Inside the VM (ubuntu-free5gc)
uname -r

A.2 Install Go

Install Go 1.2.18 and update .bashrc for it.
NOTE: sudo is not needed. Download the tar.gz file in Downloads.

Inside the VM (ubuntu-free5gc)
mkdir Downloads
cd Downloads
wget https://dl.google.com/go/go1.21.8.linux-amd64.tar.gz
tar -C /usr/local -zxvf go1.21.8.linux-amd64.tar.gz
mkdir -p ~/go/{bin,pkg,src}
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export GOROOT=/usr/local/go' >> ~/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin:$GOROOT/bin' >> ~/.bashrc
echo 'export GO111MODULE=auto' >> ~/.bashrc
source ~/.bashrc
cd ~

A.3 Install dependencies for Control Plane Elements

Install dependencies for Control Plane Elements.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
apt -y update
apt -y install wget git

Check whether AVX is supported by your CPU.
NOTE: This document assumes it is supported. See Ref1 if not supported in your environment.

Inside the VM (ubuntu-free5gc)
lscpu | grep avx

Install dependencies for MongoDB Community Edition.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
apt install -y gnupg curl
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor

Create a source list file for MongoDB.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list

Reload the source list, and install MogoDB packages.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
apt update
apt install -y mongodb-org

Start and enable MongoDB.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
systemctl start mongod
systemctl status mongod
systemctl enable mongod

A.4 Install dependencies for UPF

Install dependencies for UPF.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
apt -y update
apt -y install git gcc g++ cmake autoconf libtool pkg-config libmnl-dev libyaml-dev
uname -r
apt -y install linux-headers-5.4.0-204-generic

A.5 Linux Host Network Settings

NOTE: sudo is not needed. This VM does not run ufw service then stop ufw is ommited.

Inside the VM (ubuntu-free5gc)
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o enp5s0 -j MASQUERADE
iptables -A FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1400

B Install Control Plane Elements

B.1 Clone free5gc repository

To install the latest stable build (v3.4.4)

Inside the VM (ubuntu-free5gc)
cd ~
git clone --recursive -b v3.4.4 -j `nproc` https://github.com/free5gc/free5gc.git
cd free5gc

B.2 Compile all Control Plane Elements and also UPF

To build all network functions (AMF, SMF, etc) and also UPF:

Inside the VM (ubuntu-free5gc)
cd ~/free5gc
make

C Install UPF

Retrieve the 5G GTP-U kernel module using git and build it.
NOTE: sudo is not needed. Return to the home (cd ~) at first. Note that UPF itself was already compiled as in section B.2 of this document. lsmod is just to confirm that gtp5g is there.

Inside the VM (ubuntu-free5gc)
cd ~
git clone -b v0.9.5 https://github.com/free5gc/gtp5g.git
cd gtp5g
make
make install
lsmod | grep gtp5g
cd ~

D Install WebConsole

Install nodejs.
NOTE: sudo is not needed.

Inside the VM (ubuntu-free5gc)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - 
apt update
apt install -y nodejs
corepack enable

Build WebConsole manually.

Inside the VM (ubuntu-free5gc)
cd ~/free5gc/webconsole/frontend
yarn install
yarn build
rm -rf ../public
cp -R build ../public
cd ..
go build -o bin/webconsole server.go

E Test free5gc

Run the tests as per Ref2. All tests should be passed (ok) normally.

Ref2: https://free5gc.org/guide/4-test-free5gc/

Exit from the VM.

Inside the VM (ubuntu-free5gc)
exit

Install UERANSIM on VM (ubuntu-ueransim)

1 Check IP reachability

Now 2 VMs are running. Check the IP reachability between VMs over the 2nd NICs.

incus exec ubuntu-ueransim -- bash
(ubuntu-ueransim)# ping 192.168.56.101
(ubuntu-ueransim)# exit

incus exec ubuntu-free5gc -- bash
(ubuntu-free5gc)# ping 192.168.56.102
(ubuntu-free5gc)# exit

2 Install UERANSIM and testing UERANSIM against free5gc

Judt refer to all steps described in Ref3.
NOTE: Skip steps of 1. Install ueransim VM because a VM for UERANSIM is ready.

Ref3: https://free5gc.org/guide/5-install-ueransim/

That's all for the free5gc on Incus.

The previous document:
How to run free5GC on Incus (1of2): free5GC VM preparation on Incus

Discussion