Chapter 8: free5GC Deployment and Configuration
The official free5GC website provides a series of deployment guides. In this chapter, we will focus on deployments using bare-metal hosts (including VMs) as well as Docker-based containerized environments. Rather than only showing how to deploy free5GC, this chapter explains how to configure NF configuration files and compile the source code correctly, helping readers understand why these parameters need to be set. This deeper understanding will make it much easier to adjust deployment architectures when using free5GC for future research or experiments.
Note
The default environment assumed throughout this book is Ubuntu 24.04.
8.1 Installing the GTP5G Kernel Module
8.1.1 GTP5G Installation
The gtp5g Linux kernel module is a critical component in any free5GC deployment. Whether you deploy it on a bare-metal host (including VMs), run the UPF using Docker containers, or even adopt more advanced Kubernetes-based architectures in the future, gtp5g must be installed on the host (including the container host running the UPF) that actually carries UPF user-plane traffic.
The reason is: gtp5g is a Linux kernel module. The UPF itself does not directly process all GTP-U packets, instead, it relies on this kernel module to perform packet encapsulation, decapsulation, and forwarding.
-
Install required packages
-
Install GTP5G
8.1.2 Packet Forwarding
Since the kernel module is responsible for forwarding user-plane packets, IP Forward function must be enabled on the host running the UPF.
-
Disable the firewall
-
Enable forwarding
Note that the
dn_interfacefield in the second command must be replaced with the name of the host’s outbound network interface.
8.2 Bare-Metal Deployment (Including VM Deployment)
8.2.1 Installing Go
Note
The Go version currently used by the official free5GC project is Go 1.25.5.
-
Install Go
wget https://dl.google.com/go/go1.25.5.linux-amd64.tar.gz sudo tar -C /usr/local -zxvf go1.25.5.linux-amd64.tar.gz mkdir -p ~/go/{bin,pkg,src} # The following assume that your shell is bash: 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 -
Verify installation
If the Go version is displayed, the installation was successful!
8.2.2 Fetching and Building free5GC Source Code
-
Clone the official repository from GitHub
Note
-j
nprocargument enables parallel downloading for faster cloning!The --recursive option ensures that, in addition to the main free5GC repository, all NFs included as Git submodules are also downloaded.
-
Compilation
-
Modify configuration files
Before starting free5GC, configuration files for three NFs must be modified: AMF, SMF, and UPF. These changes allow the core network to accept connections from an external gNB.
-
AMF (~/free5gc/config/amfcfg.yaml)
Replace
ngapIpListwith the IP address of the host’s external network interface. This allows the gNB to connect to the AMF using this IP address. -
SMF (~/free5gc/config/smfcfg.yaml)
Replace the N3 interface endpoint IP in
interfaceswith the UPF’s user-plane-facing IP. This allows the SMF to inform the gNB where to establish the user-plane connection. -
UPF (~/free5gc/config/upfcfg.yaml)
Replace the
ifListaddress ingtpuwith the UPF’s external interface IP so the gNB can connect to the UPF using this IP address.
-
-
Execution
After completing the configuration file modifications, you can use the execution scripts provided in the free5GC project to start the entire core network with a single command.
Once started, you will see extensive log output. If no ERROR messages appear, the core network has been successfully launched.
8.3 Docker Docker-Based Containerized Deployment
In addition to bare-metal execution, free5GC also provides Docker Compose configurations for quickly deploying the core network. Two approaches are supported: using official images or building images locally.
Caution
Before proceeding, install Docker Engine by following the instructions on the official Docker website.
8.3.1 Using Official Images
-
Clone the free5GC Compose repository
-
Start the Compose deployment
After the images are pulled, the core network will start automatically, with each NF running in its own container.
-
Stop the Compose deployment
You can press Ctrl+C to stop the containers, which will display the container shutdown logs. However, you still need to use the
downcommand to fully shut down the Compose.
8.3.2 Building Images Locally
-
Clone the free5GC Compose repository
-
Enter the
basedirectory and fetch the free5GC source code to build the Docker image -
Build the Docker images with command
make -
Start the Compose deployment using locally built images
-
Stop the Compose deployment
8.4 Chapter Summary
In this chapter, we walked through a complete free5GC deployment from a hands-on perspective. We first explained why the gtp5g kernel module must be installed on the host that carries UPF traffic, and demonstrated how to enable IP forwarding and basic NAT / MTU settings so that the UPF can correctly forward user-plane packets. We then covered installing Go, fetching and compiling the free5GC source code on a bare-metal (or VM) environment, and modifying key AMF / SMF / UPF configuration fields related to external gNB connectivity, followed by launching the entire core network using run.sh.
Building on this foundation, we demonstrated how to deploy free5GC using Docker Compose, either with official images or locally built images, allowing readers to choose between “bare-metal deployment” and “containerized deployment” based on their needs. With these steps and the underlying rationale clearly understood, you should now be able to repeatedly rebuild and adjust free5GC in your own lab environment, laying a solid foundation for further exploration of RAN, UE, and more advanced networking scenarios.