free5gc的实践(一)

  • A+
所属分类:安全文章

总结一下free5gc的安装过程,

两个虚机,一个5gc包括upf,另一个ue&ran,双方通过第二个网卡互联,

ubuntu18.04,先换内核,sudo su -,

apt-get install -qq linux-image-5.0.0-23-generic linux-modules-5.0.0-23-generic linux-headers-5.0.0-23-generic && grub-set-default 1 && update-grub,重启,reboot,

安装go,wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz,

sudo tar -C /usr/local -zxvf go1.14.4.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,

安装mongodb,sudo apt -y update,

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

安装其它软件,

sudo apt -y install gcc cmake autoconf libtool pkg-config libmnl-dev libyaml-dev,

go get -u github.com/sirupsen/logrus,

下载编译free5gc,

git clone --recursive -b v3.0.5 -j `nproc` https://github.com/free5gc/free5gc.git,cd free5gc,make,

下载编译gtp,cd ~,

git clone -b v0.2.1 https://github.com/PrinzOwO/gtp5g.git,

cd gtp5g,make,sudo make install,

安装启用界面,

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,
cd ~/free5gc/webconsole,git checkout v1.0.1,cd ~/free5gc,
make webconsole,cd ~/free5gc/webconsole,go run server.go,

安装ue&ran,git clone https://github.com/aligungr/UERANSIM,
sudo apt install libsctp-dev lksctp-tools,
sudo snap install cmake --classic,sudo apt remove cmake,
cd UERANSIM,make,

做环境配置,cd free5gc,
sudo vim config/amfcfg.yaml,
...
  ngapIpList:  # the IP list of N2 interfaces on this AMF
  - 192.168.56.101  # 127.0.0.1
sudo vim config/smfcfg.yaml,
...
  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.56.101  # 127.0.0.8
sudo vim NFs/upf/build/config/upfcfg.yaml,
...
  gtpu:
  - addr: 192.168.56.101  # 127.0.0.8
cd UERANSIM,sudo vim config/free5gc-gnb.yaml,
...
  ngapIp: 192.168.56.102  # 127.0.0.1   # gNB's local IP address for N2 Interface (Usually same with local IP)
  gtpIp: 192.168.56.102  # 127.0.0.1    # gNB's local IP address for N3 Interface (Usually same with local IP)
  # List of AMF address information
  amfConfigs:
    - address: 192.168.56.101  # 127.0.0.1
sudo vim config/free5gc-ue.yaml,opType: 'OP',

5gc包括upf的虚机上,

sudo sysctl -w net.ipv4.ip_forward=1,
sudo iptables -t nat -A POSTROUTING -o ens32 -j MASQUERADE,
sudo systemctl stop ufw,
sudo iptables -I FORWARD 1 -j ACCEPT,

启动服务,cd free5gc,./run.sh,
cd UERANSIM,build/nr-gnb -c config/free5gc-gnb.yaml,
cd UERANSIM,sudo build/nr-ue -c config/free5gc-ue.yaml,
测试,可通,ping -I uesimtun0 baidu.com

本文始发于微信公众号(云计算和网络安全技术实践):free5gc的实践(一)

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: