Docs
Adding a Router on a New Port
When you connect a router that sends NetFlow to a new UDP port, that port must be opened in docker-compose.yml and a matching source added to nfsen.conf. Both steps take about 3 seconds.
How it actually works (router to graph)
Router to graph
Your router
sends UDP NetFlow to the VPS
VPS port 2070
Docker publishes the UDP port into the container
nfcapd collector
started from the nfsen.conf source for that port
nfsen-data/live/<router>/
raw flow files
nfsen-stat/live/<router>.rrd
RRD graphs (every 5 min)
Web UI · :8070/nfsen.php
graphs, top talkers, and drill-downs
- Your router sends NetFlow to your VPS IP on a UDP port (e.g.
2070). - Docker must forward that UDP port into the container — that is the
ports:line indocker-compose.yml. Without it, the packets are dropped before NfSen ever sees them. - nfcapd must listen on that port — that is the router source in
nfsen.conf.nfsen reconfigstarts one collector (nfcapd) per port automatically. - nfcapd writes the raw flow files into
/var/nfsen/profiles-data/live/<router>/— which is yournfsen-data/live/<router>/folder (bind mount). - nfsend turns them into graphs (RRD files) in
/var/nfsen/profiles-stat/live/. - The Web UI (port 8070) reads those RRD files and draws the charts.
Step-by-step (example: new router on port 2070)
1. Open the port in docker-compose.yml
ports:
- "8070:8070"
- "2055:2055/udp"
- "2056:2056/udp"
- "2070:2070/udp" # <- new router port2. Add the router source
docker exec is the recommended way, and it now persists forever:
docker exec netlens bash -c "sed -i \"/^);$/i\\ 'myrouter' => { 'port' => '2070', 'col' => '#FF0000', 'type' => 'netflow' },\" /var/nfsen/etc/nfsen.conf && /var/nfsen/bin/nfsen reconfig && echo 'Done'"Prefer the env var? You can set NFSEN_SOURCES=2070:myrouter:#FF0000 in docker-compose.yml instead — but pick one method, don't mix.
3. Recreate the container — done
docker compose up -dThat's it: the port opens and the router source is configured automatically. Takes ~3 seconds.
No rebuild, no data loss
docker compose up -d keeps all your NetFlow data (it lives in the nfsen-data/ folder next to docker-compose.yml).What each step did
- Adding
- "2070:2070/udp"toports:makes Docker start forwarding UDP 2070 from the VPS into the container. - The
docker execcommand adds the'myrouter'source tonfsen.conf(which lives innfsen-etc/on the host) and runsnfsen reconfig— reconfig starts annfcapdcollector on port 2070 and creates thenfsen-data/live/myrouter/folder. docker compose up -drecreates the container so the new port mapping takes effect (the image is not rebuilt).
Replace or remove the demo router1 source
The container ships with a demo source router1 on port 2055 so the Web UI shows graphs on first install. Remove or replace it once you connect a real router:
docker exec netlens bash -c "sed -i \"/'router1' =>/d\" /var/nfsen/etc/nfsen.conf && /var/nfsen/bin/nfsen reconfig && echo 'Removed'"Keep the demo gone permanently
%sources list ever becomes completely empty (e.g. you remove router1 and have no other routers yet), the demo is re-seeded automatically on the next container start. Once you have any real router, the demo never comes back.