NETCONF scripts for LNU Campus Network
BRAS 设备 IPoE 认证用户 IPv6 地址溯源程序
一、工作原理
本程序通过 NETCONF 协议获得 BRAS 设备 IPoE 认证用户 MAC、IPv4、IPv6 地址信息,并发送到 syslog 进行记录。可以通过 cron 每十分钟定时执行本程序,记录用户地址信息,以供事后溯源。
本程序在 H3C SR8808-X 以及华为 ME60 上进行了测试。华为 ME60 的 V800R013C00SPC100 版本软件 NETCONF 接口存在问题,无法正常获得 IPv6 地址。
二、开发环境
本项目使用了 UV 设置开发环境,src/netconf_lnu/mytest.py 中的函数可以作为测试使用,具体命令类似如下:
uv run netconf-lnu -c config/config.ini -t dispatch_test
其中 config/config.ini 是配置文件,可以参考 config/config.ini.example 来编写。
在 src/netconf_lnu/mytest.py 程序中的 download_schema 函数,能够下载网络设备的 YANG 文件,用户可以参考该测试函数编写自己的下载程序。
对于下载后的 YANG 文件,可以利用已经安装的 pyang 程序来浏览,命令如下:
uv run pyang -f tree schema/huawei-bras-user-manage.yang
虽然可以从设备上获得 YANG 文件,但还是建议在 Netconf Central 查找并浏览。
对于程序基本功能可以通过下面命令进行测试:
uv run netconf-lnu -c config/config.ini
三、打包部署
本项目可以通过 uv build 命令可以打包,方便修改后部署。
项目已经在 PyPI 上发布,可以直接通过 pipx 安装,以 Debian 类系统为例,可以以 root 用户执行如下命令安装 pipx:
apt install pipx
cat >> ~/.bashrc << EOF
# For pipx
export PIPX_HOME=/opt/pipx
export PIPX_BIN_DIR=/usr/local/bin
EOF
然后重新登陆系统并安装 netconf-lnu
pipx install netconf-lnu
安装后需要建立配置文件 /etc/netconf-lnu/config.ini 并运行 netconf-lnu 命令测试。
测试无误后,可以建立 cron 配置文件 /etc/cron.d/netconf-lnu,每20分钟运行程序一次,其内容如下:
*/10 * * * * root /usr/local/bin/netconf-lnu
Metadata
Release files for netconf-lnu 2025.1.16.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netconf_lnu-2025.1.16.1.tar.gz | 78.2 kB | Without provenance | Details for netconf_lnu-2025.1.16.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netconf_lnu-2025.1.16.1-py3-none-any.whl | Python 3 | none | any | Details for netconf_lnu-2025.1.16.1-py3-none-any.whl |
Total release size: 87.1 kB
Release files / netconf_lnu-2025.1.16.1.tar.gz
| Download URL | netconf_lnu-2025.1.16.1.tar.gz |
|---|---|
| Size | 78.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79a1bddda88ca9e2efc439ca7a8b50e750dd3299c517ad64f33be130cfb8f6a6
|
|
BLAKE2b-256 checksum How to use checksums |
2acffd15e5c0cb7dbce8a1efaea31d0b128f598db9e3d7ca19f4cc081498e815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.15
|
Release files / netconf_lnu-2025.1.16.1-py3-none-any.whl
| Download URL | netconf_lnu-2025.1.16.1-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5223f44f8a6106c1fd3cd9895f899cc97fc2776cd3517ca30fd978d7056cdc3d
|
|
BLAKE2b-256 checksum How to use checksums |
735901061e599085cd61dde66508dffbd83b5eec7ed5e349f85cb94d19e6b0f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.15
|
Security for netconf-lnu 2025.1.16.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.