Installing and Testing free5GC

In this demo we will practice

Please notice that the installation procedure is based on free5GC Official Site

You should refer to the information above for future installation and configuration in the future. The demo here is just for illustration of the general concepts.

1. Check OS Versions

First issue uname -r to see the Linux kernel version. If you installed Ubuntu 20.04, the version looks like 5.4.x.

$ uname -r

Please make sure your kernel version is 5.0.0-23-generic or newer than 5.4.0.

2. Install Basic Tools

First make sure Golang (go) is not installed:

go version

If go is installed, remove it first (assuming it is installed at /usr/local/go):

sudo rm -rf /usr/local/go

To install latest go, search “ubunto golan install” on the web, and get the web site: Download and install

On the web site page, choose Linux, and obtain the download URL ( by right clicking the box “Download Go for Linux” and chose something like “Copy link address”). The URL address looks like:

With the URL address, we can install the latest go using:

cd ~
sudo tar -C /usr/local -xzf go1.15.8.linux-amd64.tar.gz

Then execute the following commands (copy and paste):

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

And check if go is installed successfully:

go version

Next, we will install MongoDb. Copy and paste:

sudo apt -y update
sudo apt -y install mongodb
sudo systemctl start mongodb

You can check if MongoDb is installed by


If you can enter MongoDB’s command shell, it is installed successfully. You can exit the command shell by enter exit, or just type Ctrl-D.

Next, let’s install other development tools. Copy and paste:

sudo apt -y install git gcc g++ cmake autoconf libtool pkg-config libmnl-dev libyaml-dev
go get -u

Refer to video Install Tools

3. Setting up Networking

To setup network rules, copy and paste:

sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
sudo systemctl stop ufw

Note: The name enp0s3 is the network interface free5GC use to connect to Data Network (i.e. Internet). We already know how to get it by using ifconfig and route commands. You should change it to the name corresponding to the interface name that can reach internet.

Also note that these network settings will disappear after reboot. So make sure you run the above commands after each reboot. (You can search the web and find ways to make the settings persistent).

Refer to video Setup Routing

4. Install free5GC Core Network

Let’s install the latest free5GC directly:

cd ~
git clone --recursive

To build free5GC, do:

cd ~/free5gc

WE also need to install kernel module gtp5g:

cd ~
git clone
cd gtp5g
sudo make install

To check if gtp5g is installed successfully, see if the following command shows some information:

lsmod | grep gtp

Refer to video Install free5GC

5. Testing free5GC

free5GC provides some testing procedures to make sure it works properly. First let’s just test the basic registration procedure:

cd ~/free5gc
./ TestRegistration

If everything runs properly without “red” error messages, and the word “PASS” appears near the end of the screen output, then free5GC is running properly.

We can further check other free5GC procedures:

./ TestGUTIRegistration

./ TestServiceRequest

./ TestXnHandover

./ TestDeregistration

./ TestPDUSessionReleaseRequest

./ TestPaging

./ TestN2Handover

./ TestNon3GPP

./ TestReSynchronisation

./ -om 3 TestRegistration

Refer to video Testing free5GC