# 20180914_5G Workshop Commands - NextEPC part
# KVM installation
```
sudo apt-get -y install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
sudo adduser `id -un` libvirtd
sudo virsh list --all
sudo apt-get install virt-manager
sudo virt-manager
```
---
# NextEPC installation
1. Install Mongo DB
```
sudo apt-get update
sudo apt-get -y install mongodb
sudo systemctl start mongodb
```
2. Set TUN device
```
ls -al /dev/net/tun
```
If it is not "**crw-rw-rw- 1 root 28 10, 200 Feb 11 05:13 /dev/net/tun**", then
```
chmod 666 /dev/net/tun
```
3. Write the configuration file for the TUN deivce
```
sudo sh -c "cat << EOF > /etc/systemd/network/99-nextepc.netdev
[NetDev]
Name=pgwtun
Kind=tun
EOF"
```
4. Create the TUN device
```
sudo systemctl enable systemd-networkd
sudo systemctl restart systemd-networkd
sudo apt-get -y install net-tools
ifconfig pgwtun
```
5. Check IPv6 Kernel Configuration
```
sysctl -n net.ipv6.conf.pgwtun.disable_ipv6
(if the output is 0 and IPv6 is enabled, skip the following 2 lines)
sudo sh -c "echo 'net.ipv6.conf.pgwtun.disable_ipv6=0' > /etc/sysctl.d/30-nextepc.conf"
sudo sysctl -p /etc/sysctl.d/30-nextepc.conf
```
6. Set the IP address on TUN device
```
sudo sh -c "cat << EOF > /etc/systemd/network/99-nextepc.network
[Match]
Name=pgwtun
[Network]
Address=45.45.0.1/16
Address=cafe::1/64
EOF"
sudo systemctl enable systemd-networkd
sudo systemctl restart systemd-networkd
ifconfig pgwtun
```
7. Install the necessary packages (15x packages)
```
sudo apt-get -y install autoconf libtool gcc pkg-config git flex bison libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev libbson-dev libyaml-dev
```
8. Git clone and compile
```
git clone https://github.com/acetcom/nextepc
cd nextepc
autoreconf -iv
./configure --prefix=`pwd`/install
make -j `nproc`
make install
```
9. Verify the installation
```
./test/testepc
```
---
# WebUI installation
10. Install npm and Nodejs for webui to control HSS database
```
sudo apt-get -y install curl
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get -y install nodejs
cd webui
npm install
```
11. Run WebUI
```
npm run dev
```
12. Add new user to HSS database
```
Connect to http://localhost:3000/
Account: admin / Password: 1423
Click “+” buttion
Fill the K/OPc/IMSI and click “Save”
```
SIM card Information
:::info
IMSI: 208930000000003
OPc: 8e27b6af0e692e750f32667a3b14605d
K: 8baf473f2f8fd09487cccbd7097c6862
:::
13. Modify the configuration of NextEPC
```
gedit ./install/etc/nextepc/nextepc.conf
```

14. Set the rule for forwading packets from NextEPC to Internet
```
sudo ifconfig ens38 192.188.2.2
sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
sudo iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE
sudo iptables -I INPUT -i pgwtun -j ACCEPT
```
---
# Run nextepc
```
./nextepc-epcd
```