To store state data and configuration FastNetMon uses MongoDB and we will need to install it first.
You can deploy FastNetMon on Docker using our official Docker images.
To keep MongoDB data and FastNetMon configuration and state we will use folders from host and we need to create them this way:
sudo mkdir /var/lib/fastnetmon_docker
And then create folders for MongoDB:
sudo mkdir /var/lib/fastnetmon_docker/mongodb sudo mkdir /var/lib/fastnetmon_docker/mongodb/data
And then create folders for FastNetMon:
sudo mkdir /var/lib/fastnetmon_docker/fastnetmon sudo mkdir /var/lib/fastnetmon_docker/fastnetmon/logs sudo mkdir /var/lib/fastnetmon_docker/fastnetmon/conf sudo mkdir /var/lib/fastnetmon_docker/fastnetmon/conf/keychain
First of all we need to create private network to use it between FastNetMon and MongoDB for additional security:
sudo docker network create fastnetmon-network
Check that network was created successfully:
sudo docker network ls
Example output:
NETWORK ID NAME DRIVER SCOPE 684149c93997 bridge bridge local 3598a7913410 fastnetmon-network bridge local a4eebee9cf76 host host local 9a2c93f8408a none null local
Then pull latest MongoDB 6 image based on Ubuntu 22.04:
sudo docker pull mongo:latest
Then generate password for MongoDB:
MONGO_PASSWORD=`printf "%s" $(pwgen 16 1)`
Save it to FastNetMon configuration for fcli and FastNetMon daemon:
echo -n $MONGO_PASSWORD | sudo tee /var/lib/fastnetmon_docker/fastnetmon/conf/keychain/.mongo_fastnetmon_password
And then run it:
sudo docker run --name mongo-server.networkd --network fastnetmon-network -p 127.0.0.1:27017:27017/tcp -v /var/lib/fastnetmon_docker/mongodb/data:/data/db --restart always -e MONGO_INITDB_ROOT_USERNAME=administrator -e MONGO_INITDB_ROOT_PASSWORD=$MONGO_PASSWORD -d mongo:latest
Then confirm that MongoDB is running fine:
sudo docker exec -it mongo-server.networkd mongosh --authenticationDatabase admin --username administrator -password `cat /var/lib/fastnetmon_docker/fastnetmon/conf/keychain/.mongo_fastnetmon_password` --eval 'db.version()'
The next step is to configure FastNetMon:
Put following data to /var/lib/fastnetmon_docker/fastnetmon/conf/fastnetmon.conf:
{ "mongodb_host": "mongo-server.networkd", "mongodb_port": 27017, "mongodb_database_name": "fastnetmon", "mongodb_username": "administrator", "mongodb_auth_source": "admin" }
Then pull FastNetMon Advanced image:
sudo docker pull fastnetmonltd/fastnetmon-advanced:latest
Then we need to run fcli command line tool to create configuration in MongoDB, we need to do it before running FastNetMon:
sudo docker run --network fastnetmon-network -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon fastnetmonltd/fastnetmon-advanced:latest fcli create_configuration
Then check that configuration is present:
sudo docker run --network fastnetmon-network -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon fastnetmonltd/fastnetmon-advanced:latest fcli show main api_host
Then enable local API to bind on all available interfaces, we need it to have access to internal API access from fcli:
sudo docker run --network fastnetmon-network -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon fastnetmonltd/fastnetmon-advanced:latest fcli set main api_host 0.0.0.0
Then finally run FastNetMon:
sudo docker run --name fastnetmon-server.networkd --cap-add=NET_ADMIN --cap-add=CAP_IPC_LOCK --network fastnetmon-network -p "0.0.0.0:6343:6343/udp" -p "0.0.0.0:2055:2055/udp" -v /var/lib/fastnetmon_docker/fastnetmon/logs:/var/log/fastnetmon -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon --restart always -d --init fastnetmonltd/fastnetmon-advanced:latest
If you do not have plans to use port mirror or AF_XDP based capture then you can skip NET_ADMIN and CAP_IPC_LOCK flags.
Then you can confirm that FastNetMon is running correctly using this command:
ps aux|grep fastnetmon
Example output:
root 11145 0.0 0.0 1112 4 ? Ss 17:03 0:00 /sbin/docker-init -- /bin/sh -c exec /opt/fastnetmon/app/bin/fastnetmon root 11195 0.0 0.2 801120 32964 ? Sl 17:03 0:00 /opt/fastnetmon/app/bin/fastnetmon
If you have any issues you may check content of log file:
/var/lib/fastnetmon_docker/fastnetmon/logs/fastnetmon.log
If you need to change configuration of FastNetMon then instead of sudo fcli commit you need to restart container with FastNetMon this way:
sudo docker restart fastnetmon-server.networkd
Finally, connect to FastNetMon internal API and MongoDB in same time from fcli:
sudo API_HOST=fastnetmon-server.networkd docker run -e API_HOST --network fastnetmon-network -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon fastnetmonltd/fastnetmon-advanced:latest fcli show system_counters
You will see real time counters from FastNetMon.
Or you can run fcli in interactive mode:
sudo API_HOST=fastnetmon-server.networkd docker run -e API_HOST --network fastnetmon-network -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon -it fastnetmonltd/fastnetmon-advanced:latest fcli
You may run API daemon in a similar way using this command:
sudo API_HOST=fastnetmon-server.networkd HTTP_API_MODE=on docker run -e API_HOST -e HTTP_API_MODE --network fastnetmon-network -v /var/lib/fastnetmon_docker/fastnetmon/conf:/etc/fastnetmon -it fastnetmonltd/fastnetmon-advanced:latest fcli