3. Creating and Configuring a free5GC VM - anhtien17/free5GC GitHub Wiki
The aims of this guide are:
- Cloning an existing VM to install
free5GC
- Installing and testing the
free5GC
core network - Configuring
free5GC
.
free5GC
VM
A. Create A 1. Clone a VM
First, let’s clone a new VM:
- Select an existing VM (ubuntu) and Right-click and choose
Clone
- Name the new VM as
free5gc
- The MAC address rule:
Create new MAC addresses for all network cards
- Choose the
Full Clone
option.
2. Change Hostname
-
The cloned free5gc VM still has the hostname
ubuntu
(or the name you gave it in the original VM). Let’s rename the VM tofree5gc
. You can do this by editing the file/etc/hostname
(using vi or nano):sudo nano /etc/hostname # or sudo vi /etc/hostname
-
Then, change the file
/etc/hosts
by replacing theubuntu
inside intofree5gc
:sudo nano /etc/hosts
3. Set Static IP
- Now we change the IP of free5gc machine to a static IP (in the IP's range of your network), e.g.,
192.168.31.101/24
. You also need change the DNS's mode from Automatically to Manual (8.8.8.8
).
free5GC
Core Network
B. Install & Test 1. 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 the latest go, search
golang
on the web, and get the website: Golang. On the website page, choose Linux, and obtain the download URL (by right-clicking the boxDownload Go for Linux
and chose something likeCopy link address
). The URL address looks like this:https://golang.org/dl/go1.17.linux-amd64.tar.gz
-
With the URL address, we can install the latest
go
using:cd ~ wget https://golang.org/dl/go1.17.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.17.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:
sudo apt -y update sudo apt -y install mongodb sudo systemctl start mongodb
-
Finally, install other development tools:
sudo apt -y install git gcc g++ cmake autoconf libtool pkg-config libmnl-dev libyaml-dev go get -u github.com/sirupsen/logrus
2. Set 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).
- These network settings will disappear after reboot. So make sure you run the above commands after each reboot.
3. Install free5GC Core Network
-
Let’s install the latest free5GC directly:
cd ~ git clone --recursive https://github.com/free5gc/free5gc.git
-
To build free5GC, do:
cd ~/free5gc make
-
We also need to install kernel module gtp5g:
cd ~ git clone https://github.com/PrinzOwO/gtp5g.git cd gtp5g make sudo make install
-
To check if gtp5g is installed successfully, see if the following command shows some information:
lsmod | grep gtp
4. Testing free5GC
-
free5GC provides some testing procedures to make sure it works properly. First let’s just test the basic registration procedure:
cd ~/free5gc ./test.sh TestRegistration
-
If everything runs properly without
Red
error messages, and the wordPASS
appears near the end of the screen output, then free5GC is running properly. -
We can further check other free5GC procedures:
./test.sh TestGUTIRegistration ./test.sh TestServiceRequest ./test.sh TestXnHandover ./test.sh TestDeregistration ./test.sh TestPDUSessionReleaseRequest ./test.sh TestPaging ./test.sh TestN2Handover ./test.sh TestNon3GPP ./test.sh TestReSynchronisation ./test_ulcl.sh -om 3 TestRegistration
free5GC
C. Configuring 1. Install free5GC WebConsole
-
free5GC provides a simple web tool WebConsole to help to create and manage UE registrations to be used by various 5G network functions (NF). To build WebConsole we need Node.js and Yarn.
-
First, remove obsolete tools that may exist:
sudo apt remove cmdtest sudo apt remove yarn
-
Then, install Node.js and Yarn:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update sudo apt-get install -y nodejs yarn
-
Build WebConsole:
cd ~/free5gc make webconsole
2. Add a UE via WebConsole
-
First, start up the WebConsole server:
cd ~/free5gc/webconsole go run server.go
-
The result screen shows the port number :5000 at the end. Open your web browser from your host machine, and enter the following URL (the IP address of free5gc +
:5000
):http://192.168.31.101:5000
-
On the login page, enter username
admin
and passwordfree5gc
-
Once logged in, widen the page until you see
Subscribers
tab on the left-hand side column. -
Choose
Subscribers
tab and create a new data- Note that other than the
Operator Code Type
field which you should chooseOP
for now, leave other fields unchanged. This registration data is used for ease of testing and actual use later.
- Note that other than the
-
After the data is created successfully, you can press
Ctrl-C
on the terminal to quit WebConsole.
-
3. Setting free5GC Parameters
In free5gc VM, we need to edit three files:
* ~/free5gc/config/amfcfg.yaml
* ~/free5gc/config/smfcfg.yaml
* ~/free5gc/NFs/upf/build/config/upfcfg.yaml
-
First, change file
amfcfg.yaml
in path: ~/free5gc/config/amfcfg.yamlReplace
ngapIpList
IP from127.0.0.1
to the IP address of free5gc, e.g.,192.168.31.101
... ngapIpList: # the IP list of N2 interfaces on this AMF - 192.168.31.101 # 127.0.0.1
-
Next, edit file
smfcfg
in path: ~/free5gc/config/smfcfg.yamlReplace
UPF
IP from127.0.0.1
to the IP address of free5gc, e.g.,192.168.31.101
... interfaces: # Interface list for this UPF - interfaceType: N3 # the type of the interface (N3 or N9) endpoints: # the IP address of this N3/N9 interface on this UPF - 192.168.31.101 # 127.0.0.8
-
Finally, edit file
upfcfg
in path: ~/free5gc/NFs/upf/build/config/upfcfg.yamlReplace
gtpu
IP from127.0.0.1
to the IP address of free5gc, e.g.,192.168.31.101
... gtpu: - addr: 192.168.31.101 # 127.0.0.8