
LanLens 是一款开源的、自托管的局域网监控与设备管理仪表盘。它通过 ARP 扫描自动发现网络中的设备,并提供一个清晰的 Web 界面,让您能够对设备进行文档化记录、分类管理以及一键连接,是 NAS 用户、Homelab 玩家和小型办公室整理网络资产的得力工具。
本次实践为个人测试环境,操作系统版本为 Ubuntu 24.04.2 LTS。
hostname | IP地址 | 操作系统版本 | Docker版本 | 部署项目 | 备注 |
|---|---|---|---|---|---|
jeven | 192.168.3.88 | Ubuntu 24.04.2 LTS | 28.5.0 | LanLens | —— |
1.本次实践部署环境为个人测试环境,生产环境请谨慎;
2.在Docker环境下部署网络监控工具LanLens。
检查Docker服务是否正常运行,确保Docker正常运行。
root@jeven:~# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Thu 2026-02-05 00:27:40 CST; 1s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 841698 (dockerd)
Tasks: 65
Memory: 73.5M (peak: 77.1M)
CPU: 975ms
CGroup: /system.slice/docker.service检查Docker版本
root@jeven:~# docker -v
Docker version 28.5.0, build 887030f检查Docker compose版本,确保2.0以上版本。
root@jeven:~# docker compose version
Docker Compose version v2.39.4下载LanLens镜像,执行以下命令:
root@jeven:~# docker pull alexrosbach/lanlens:1.5.0
1.5.0: Pulling from alexrosbach/lanlens
57fb71246055: Pull complete
797809503061: Pull complete
759e0c85a86e: Pull complete
b33ff618953d: Pull complete
e1b7808202cc: Pull complete
139cd875bbee: Pull complete
9414313f16ad: Pull complete
ceb56ab7a3c0: Pull complete
337b15847b10: Pull complete
9d2ac2fde8e0: Pull complete
e4dba22d0a30: Pull complete
f29100864560: Pull complete
f142a0d21606: Pull complete
a177fd15c467: Pull complete
Digest: sha256:dd80cb40e9cb1109bf80cae9dd07b651782c9328921f8e5a6c8d43691301415d
Status: Downloaded newer image for alexrosbach/lanlens:1.5.0
docker.io/alexrosbach/lanlens:1.5.0
mkdir -p /data/lanLens/data && cd /data/lanLens chmod -R 777 /data/lanLens/执行以下命令,生成随机密钥,在后续步骤使用。
root@jeven:/data/lanLens# python3 -c "import secrets; print(secrets.token_hex(32))"
a9fd8c03fa59509dcae18042f5594221f50f0d508e2a85ce1900c5f7ac042e5a
如果想要使用docker-cli方式部署,可参考以下命令部署。(可选)
docker run -d \
--name=lanlens \
--restart=always \
--network=host \
--cap-add=NET_ADMIN \
--cap-add=NET_RAW \
-v /data/lanLens/data:/data \
-e SECRET_KEY=a9fd8c03fa59509dcae18042f5594221f50f0d508e2a85ce1900c5f7ac042e5a \
-e DEFAULT_ADMIN_PASSWORD=admin \
-e LANLENS_PORT=7765 \
-e BACKEND_PORT=17765 \
-e TZ=Asia/Shanghai \
alexrosbach/lanlens:1.5.0本次实践我们采用 Docker Compose 方式进行部署,这也是我推荐的方式。首先我们需要创建并编辑
docker-compose.yaml文件,请注意宿主机映射端口可根据您的实际情况自行设置,务必避免端口冲突。
vim docker-compose.yamlservices:
lanlens:
image: alexrosbach/lanlens:1.5.0
# To build locally instead of pulling from Docker Hub, uncomment:
# build: .
container_name: lanlens
restart: always
# Required for ARP scanning: container must share the host network stack
# so scapy can send raw Ethernet frames via the host's physical NIC.
# Remove this and uncomment 'ports' below to use bridge networking —
# but note that ARP scanning will not work in bridge mode.
network_mode: host
cap_add:
- NET_ADMIN # network interface configuration
- NET_RAW # raw socket access for ARP broadcast
volumes:
- /data/lanLens/data:/data # SQLite database + persistent state
environment:
# ── REQUIRED ──────────────────────────────────────────────────────────────
# Replace with a strong random key (min 32 chars). App refuses to start otherwise.
# Generate: python3 -c "import secrets; print(secrets.token_hex(32))"
- SECRET_KEY=a9fd8c03fa59509dcae18042f5594221f50f0d508e2a85ce1900c5f7ac042e5a
# ── OPTIONAL ──────────────────────────────────────────────────────────────
# Initial admin password (will be changed on first login)
- DEFAULT_ADMIN_PASSWORD=admin
# Host-mode HTTP port for the LanLens UI (for example 80, 8080, 7765)
- LANLENS_PORT=7765
# Internal API port used behind nginx (leave as-is unless you know why)
- BACKEND_PORT=17765
# Timezone (e.g. Europe/Berlin, America/New_York, UTC)
- TZ=Asia/Shanghai
# Host mode still allows a custom HTTP port.
# Example: set LANLENS_PORT=80 above if you want LanLens on port 80.
# ── Bridge networking alternative (ARP scanning disabled) ─────────────────
# Comment out network_mode and cap_add above, then uncomment:
# ports:
# - "8080:8080"
# and set LANLENS_PORT=8080 above so nginx listens on the same port.
healthcheck:
test: ["CMD-SHELL", "curl -fs http://localhost:$${LANLENS_PORT:-7765}/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
配置项 | 默认值 | 解释 |
|---|---|---|
| 无(必需) | 至少32位的随机字符串,用于加密凭据存储。 |
|
| 初始管理员密码,首次登录后请务必修改。 |
|
| LanLens Web UI 的 HTTP 服务端口。 |
|
| 内部 FastAPI 后端端口,通常无需修改。 |
|
| SQLite 数据库文件的存储路径。 |
|
| 设置容器运行时的时区。 |
执行以下命令,创建LanLens容器。
docker compose up -d
检查LanLens容器运行状态,确保LanLens容器正常启动。
root@jeven:/data/lanLens# docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
lanlens alexrosbach/lanlens:1.5.0 "/entrypoint.sh" lanlens 30 seconds ago Up 30 seconds (healthy)
检查LanLens服务端口,确保服务端口正常监听。
root@jeven:/data/lanLens# ss -tunlp |grep 7765
tcp LISTEN 0 511 0.0.0.0:7765 0.0.0.0:* users:(("nginx",pid=1591587,fd=5),("nginx",pid=1591585,fd=5))
tcp LISTEN 0 2048 127.0.0.1:17765 0.0.0.0:* users:(("uvicorn",pid=1591559,fd=12))检查容器运行日志,确保LanLens服务正常运行。
docker compose logs
浏览器地址:
http://<个人的服务器IP>:7765,访问LanLens初始页。如果无法访问,请确保宿主机的防火墙已关闭或已放行相关端口,对于云服务器还需配置相应的安全组规则。

默认账号密码为admin/admin,第一次登录需要修改密码,更改密码后可进入LanLens首页。


在系统设置中,将语言选择位简体中文,保存设置即可。

在网段模块,自行添加需要的扫描的内网网段。

在仪表盘中,我们选择需要扫描的网段,点击【立即扫描】即可。

本次在本地Docker环境部署LanLens的过程流畅高效,从环境检查到镜像拉取、容器创建,各环节操作清晰明确。通过配置核心的
SECRET_KEY环境变量并采用host网络模式,确保了工具对局域网设备的ARP扫描能力。部署完成后,通过Web界面登录并执行简单扫描,直观呈现了设备列表及基础信息,功能展示清晰易用。LanLens以轻量化的部署方式和实用的功能,为快速整理与监控局域网设备提供了便捷途径,适合个人及小型场景使用。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。