Mac OS X

This guide is based on macOS Big Sur 11.2 on a Macbook Air(Apple M1 Chips) computer.

Install Xcode Command-Line Tools


Homebrew requires the Xcode command-line tools from Apple’s Xcode.

$ xcode-select --install

Installing Homebrew


Install brew using the official Homebrew installation instructions.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Getting MongoDB


Install MongoDB with Package Manager.

$ brew tap mongodb/brew
$ brew install mongodb-community

Run MongoDB server.

$ mongod --config /opt/homebrew/etc/mongod.conf

Tip: MongoDB is persistent after rebooting with the following commands: $ brew services start mongodb-community

Setting up network (No persistent after rebooting)


Note that Open5GS uses built-in “utun” device driver. So, You don’t have to install external TUN/TAP driver.

Configure the loopback interface.

$ sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.6 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.7 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.8 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.9 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.10 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.11 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.12 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.13 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.14 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.15 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.16 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.17 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.18 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.19 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.20 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.200 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.201 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.202 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.250 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.251 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.252 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.1.250 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.1.251 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.1.252 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.2.250 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.2.251 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.2.252 netmask 255.255.255.255

Enable IP forwarding & Masquerading

$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo sysctl -w net.inet6.ip6.forwarding=1
$ sudo sh -c "echo 'nat on {en0} from 10.45.0.0/16 to any -> {en0}' > /etc/pf.anchors/org.open5gs"
$ sudo sh -c "echo 'nat on {en0} from 2001:db8:cafe::1/48 to any -> {en0}' > /etc/pf.anchors/org.open5gs"
$ sudo pfctl -e -f /etc/pf.anchors/org.open5gs

Tip: The script provided in $GIT_REPO/misc/netconf.sh makes it easy to configure the TUN device as follows: $ sudo ./misc/netconf.sh

Building Open5GS


Install the depedencies for building the source code.

$ brew install mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd nghttp2 pkg-config bison libusrsctp libtins talloc cmake

Configure Homebrew PATH

$ export PATH="/opt/homebrew/opt/curl/bin:/opt/homebrew/opt/bison/bin:/opt/homebrew/bin:$PATH"
$ export PKG_CONFIG_PATH="/opt/homebrew/opt/curl/lib/pkgconfig:$PKG_CONFIG_PATH"
$ export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH"
$ export LIBRARY_PATH=/opt/homebrew/lib
$ export C_INCLUDE_PATH=/opt/homebrew/include
$ export CPLUS_INCLUDE_PATH=/opt/homebrew/include

Install Meson using Homebrew.

$ brew install meson

Git clone.

$ git clone https://github.com/open5gs/open5gs

To compile with meson:

$ cd open5gs
$ meson build --prefix=`pwd`/install
$ ninja -C build

Check whether the compilation is correct.

Note: This should require sudo due to access /dev/tun0.

$ sudo ./build/tests/attach/attach ## EPC Only
$ sudo ./build/tests/registration/registration ## 5G Core Only

Run all test programs as below.

Note: This should require sudo due to access /dev/tun0.

$ cd build
$ sudo meson test -v

Tip: You can also check the result of ninja -C build test with a tool that captures packets. If you are running wireshark, select the loopback interface and set FILTER to s1ap || gtpv2 || pfcp || diameter || gtp || ngap || http2.data.data || http2.headers. You can see the virtually created packets. testattach.pcapng/testregistration.pcapng

You need to perform the installation process.

$ cd build
$ ninja install
$ cd ../

Building WebUI of Open5GS


Node.js is required to build WebUI of Open5GS

$ brew install node

Install the dependencies to run WebUI

$ cd webui
$ npm ci

The WebUI runs as an npm script.

$ npm run dev