说明:
本文仅适合个人对5gc核心网感兴趣测、研究使用。
操作系统版本:
# uname -r
5.4.0-177-generic
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
修改网卡名称为eth0:
原始网卡信息:
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:22:4f:60:78:54 brd ff:ff:ff:ff:ff:ff
inet 10.121.218.48/24 brd 10.121.218.255 scope global dynamic ens5
valid_lft 100654441sec preferred_lft 100654441sec
inet6 fe80::222:4fff:fe60:7854/64 scope link
valid_lft forever preferred_lft forever
修改网卡操作:
# vim /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
修改GRUB_CMDLINE_LINUX为 --> GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-177-generic
Found initrd image: /boot/initrd.img-5.4.0-177-generic
done
# reboot
# vim /etc/netplan/00-installer-config.yaml
network:
ethernets:
eth0: #修改为eth0
dhcp4: true
version: 2
# netplan apply
如果网卡没有启动使用如下命令:
ip link set eth0 up
查看修改后网卡信息:
# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:22:4f:60:78:54 brd ff:ff:ff:ff:ff:ff
inet 10.121.218.48/24 brd 10.121.218.255 scope global dynamic eth0
valid_lft 100663242sec preferred_lft 100663242sec
inet6 fe80::222:4fff:fe60:7854/64 scope link
valid_lft forever preferred_lft forever
安装依赖安装包:
# apt update -y
# apt upgrade -y
# apt install -y curl wget apt-transport-https
安装gpt5g
# apt install gcc -y
# apt install make -y
# apt install git -y
# git clone -b v0.8.1 https://github.com/free5gc/gtp5g.git
# cd gtp5g/
# make
make -C /lib/modules/5.4.0-177-generic/build M=/root/gtp5g modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-177-generic'
CC [M] /root/gtp5g/src/gtp5g.o
CC [M] /root/gtp5g/src/log.o
CC [M] /root/gtp5g/src/util.o
CC [M] /root/gtp5g/src/gtpu/dev.o
CC [M] /root/gtp5g/src/gtpu/encap.o
CC [M] /root/gtp5g/src/gtpu/hash.o
CC [M] /root/gtp5g/src/gtpu/link.o
CC [M] /root/gtp5g/src/gtpu/net.o
CC [M] /root/gtp5g/src/gtpu/pktinfo.o
CC [M] /root/gtp5g/src/genl/genl.o
CC [M] /root/gtp5g/src/genl/genl_version.o
CC [M] /root/gtp5g/src/genl/genl_pdr.o
CC [M] /root/gtp5g/src/genl/genl_far.o
CC [M] /root/gtp5g/src/genl/genl_qer.o
CC [M] /root/gtp5g/src/genl/genl_urr.o
CC [M] /root/gtp5g/src/genl/genl_report.o
CC [M] /root/gtp5g/src/genl/genl_bar.o
CC [M] /root/gtp5g/src/pfcp/api_version.o
CC [M] /root/gtp5g/src/pfcp/pdr.o
CC [M] /root/gtp5g/src/pfcp/far.o
CC [M] /root/gtp5g/src/pfcp/qer.o
CC [M] /root/gtp5g/src/pfcp/urr.o
CC [M] /root/gtp5g/src/pfcp/bar.o
CC [M] /root/gtp5g/src/pfcp/seid.o
CC [M] /root/gtp5g/src/proc.o
LD [M] /root/gtp5g/gtp5g.o
Building modules, stage 2.
MODPOST 1 modules
CC [M] /root/gtp5g/gtp5g.mod.o
LD [M] /root/gtp5g/gtp5g.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-177-generic'
# make install
cp gtp5g.ko /lib/modules/5.4.0-177-generic/kernel/drivers/net
modprobe udp_tunnel
/sbin/depmod -a
modprobe gtp5g
echo "gtp5g" >> /etc/modules
安装docker
# apt update
# apt install apt-transport-https ca-certificates curl software-properties-common -y
# 添加Docker的官方GPG密钥
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
# 添加Docker软件库
# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# 再次更新软件库索引
# apt update
# 安装Docker CE
# apt install docker-ce -y
# 启动Docker并设置开机启动
# systemctl start docker
# systemctl enable docker
# 验证Docker安装
# docker --version
Docker version 26.1.0, build 9714adc
安装minikube
# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# cp minikube-linux-amd64 /usr/local/bin/minikube
# chmod +x /usr/local/bin/minikube
启动minikube
使用普通账号操作:
$ sudo usermod -aG docker $USER && newgrp docker
$ minikube start --driver=docker --cpus=4 --memory=16g --disk-size=100g --cni=flannel
* minikube v1.33.0 on Ubuntu 20.04 (kvm/amd64)
* Using the docker driver based on user configuration
* Using Docker driver with root privileges
* Starting "minikube" primary control-plane node in "minikube" cluster
* Pulling base image v0.0.43 ...
* Downloading Kubernetes v1.30.0 preload ...
> preloaded-images-k8s-v18-v1...: 342.90 MiB / 342.90 MiB 100.00% 16.34 M
> index.docker.io/kicbase/sta...: 480.29 MiB / 480.29 MiB 100.00% 1.13 Mi
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.43, but successfully downloaded docker.io/kicbase/stable:v0.0.43 as a fallback image
* Creating docker container (CPUs=4, Memory=16384MB) ...
* Preparing Kubernetes v1.30.0 on Docker 26.0.1 ...
- Generating certificates and keys ...
- Booting up control plane ...
- Configuring RBAC rules ...
* Configuring Flannel (Container Networking Interface) ...
* Verifying Kubernetes components...
- Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: default-storageclass, storage-provisioner
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
安装kubectl
# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
# chmod +x kubectl
# mv kubectl /usr/local/bin/
安装helm
# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
# chmod 700 get_helm.sh
# ./get_helm.sh
Downloading https://get.helm.sh/helm-v3.14.4-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm
安装multus-cni
使用普通账户执行:
$ git clone https://github.com/k8snetworkplumbingwg/multus-cni.git
$ sudo cat /home/yan/multus-cni/deployments/multus-daemonset.yml | kubectl apply -f -
[sudo] password for yan:
Sorry, try again.
[sudo] password for yan:
customresourcedefinition.apiextensions.k8s.io/network-attachment-definitions.k8s.cni.cncf.io created
clusterrole.rbac.authorization.k8s.io/multus created
clusterrolebinding.rbac.authorization.k8s.io/multus created
serviceaccount/multus created
configmap/multus-cni-config created
daemonset.apps/kube-multus-ds created
安装5GC
使用普通账户执行:
$ kubectl create ns free5gc
$ git clone https://github.com/Orange-OpenSource/towards5gs-helm.git
$ helm -n free5gc install free5gc-v1 /home/yan/towards5gs-helm/charts/free5gc --set global.n2network.masterIf=eth0,global.n4network.masterIf=eth0,global.n6network.masterIf=eth0,global.n9network.masterIf=eth0,global.n6network.subnetIP=10.244.0.0,global.n6network.gatewayIP=10.244.0.2,free5gc-upf.upf.n6if.ipAddress=10.244.0.20
NAME: free5gc-v1
LAST DEPLOYED: Fri Apr 26 09:15:45 2024
NAMESPACE: free5gc
STATUS: deployed
REVISION: 1
NOTES:
#
# Software Name : towards5gs-helm
# SPDX-FileCopyrightText: Copyright (c) 2021 Orange
# SPDX-License-Identifier: Apache-2.0
#
# This software is distributed under the Apache License 2.0,
# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE
# or see the "LICENSE" file for more details.
#
# Author: Abderaouf KHICHANE, Ilhem FAJJARI
# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes
#
#
# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm
#
1. Get the list of created Pods by running:
kubectl get pods --namespace free5gc -l "project="
Release notes (What's changed in this version):
- Fix TLS configuration for SBI communications
注意:
此次的eth0为本机的网卡名。
安装UERANSIM
$ helm -n free5gc install ueransim /home/yan/towards5gs-helm/charts/ueransim --set global.n2network.masterIf=eth0,global.n3network.masterIf=eth0
NAME: ueransim
LAST DEPLOYED: Fri Apr 26 09:18:48 2024
NAMESPACE: free5gc
STATUS: deployed
REVISION: 1
NOTES:
#
# Software Name : towards5gs-helm
# SPDX-FileCopyrightText: Copyright (c) 2021 Orange
# SPDX-License-Identifier: Apache-2.0
#
# This software is distributed under the Apache License 2.0,
# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE
# or see the "LICENSE" file for more details.
#
# Author: Abderaouf KHICHANE, Ilhem FAJJARI
# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes
#
#
# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm
#
1. Run UE connectivity test by running these commands:
helm --namespace free5gc test ueransim
If you want to run connectivity tests manually, follow:
1. Get the UE Pod name by running:
export POD_NAME=$(kubectl get pods --namespace free5gc -l "component=ue" -o jsonpath="{.items[0].metadata.name}")
2. Check that uesimtun0 interface has been created by running these commands:
kubectl --namespace free5gc logs $POD_NAME
kubectl --namespace free5gc exec -it $POD_NAME -- ip address
3. Try to access internet from the UE by running:
kubectl --namespace free5gc exec -it $POD_NAME -- ping -I uesimtun0 www.google.com
kubectl --namespace free5gc exec -it $POD_NAME -- curl --interface uesimtun0 www.google.com
kubectl --namespace free5gc exec -it $POD_NAME -- traceroute -i uesimtun0 www.google.com
Release notes (What's changed in this version):
- add the release notes
- add an initContainer to wait for the AMF to be ready
- enhance the handling of k8s NGAP service and network parameters
查看所有pod:
$ kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
free5gc free5gc-v1-free5gc-amf-amf-7844db6fd-xqs4f 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-ausf-ausf-7dcf7948f-47shs 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-dbpython-dbpython-85b5c46c66-5524c 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-nrf-nrf-75b6dd6d97-dn9bn 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-nssf-nssf-58b865c889-xf969 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-pcf-pcf-fd4b45967-pt698 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-smf-smf-75b66b95f5-vr7fj 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-udm-udm-75fd9d5ccb-lv7tl 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-udr-udr-7bff444cb4-w7vz8 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-upf-upf-9867579cf-xrwz5 1/1 Running 0 20m
free5gc free5gc-v1-free5gc-webui-webui-6497c44789-bwxxj 1/1 Running 0 20m
free5gc mongodb-0 1/1 Running 0 20m
free5gc ueransim-gnb-76545d6765-l6tmh 1/1 Running 0 17m
free5gc ueransim-ue-7cb978fd78-2dlhd 1/1 Running 0 17m
启动Web界面
$ kubectl port-forward --namespace free5gc svc/webui-service 5000:5000
Forwarding from 127.0.0.1:5000 -> 5000
Forwarding from [::1]:5000 -> 5000
本地电脑操作:
C:\Users\ailink>ssh -L localhost:5000:localhost:5000 yan@10.121.218.48
The authenticity of host '10.121.218.48 (10.121.218.48)' can't be established.
ECDSA key fingerprint is SHA256:2aiuF/m8XpMHm9sGo/6KBMmM52iWFd4mChfUcXXFvzA.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.121.218.48' (ECDSA) to the list of known hosts.
yan@10.121.218.48's password:
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-177-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Fri 26 Apr 2024 09:52:03 AM UTC
System load: 0.27
Usage of /: 5.6% of 289.30GB
Memory usage: 7%
Swap usage: 0%
Processes: 371
Users logged in: 2
IPv4 address for br-542cd42b44c7: 192.168.49.1
IPv4 address for docker0: 172.17.0.1
IPv4 address for eth0: 10.121.218.48
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
New release '22.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Fri Apr 26 08:31:48 2024 from 192.168.10.2
登陆5GCWeb界面,http://localhost:5000,用户名和秘密为admin/free5gc
本次安装到这里完毕,后续章节会补充UE和GNB接入操作。
参考网址:
链接: free5GC
链接: free5gc Helm chart