Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能不能 调用路由器的UPnP自动开放端口 #98

Open
aeeq opened this issue Feb 23, 2025 · 4 comments
Open

能不能 调用路由器的UPnP自动开放端口 #98

aeeq opened this issue Feb 23, 2025 · 4 comments

Comments

@aeeq
Copy link

aeeq commented Feb 23, 2025

因为很多时候,没有路由器的权限,不能改动防火墙,但路由器都支持 UPnP NAT-PMP功能,像qbittorrent 这类bt下载软件都是支持自动开端口。然后把 natmap 运行在主机就可以了,不用改动路由器设置。

@heiher
Copy link
Owner

heiher commented Feb 23, 2025

Natter支持UPnP: https://github.com/MikeWang000000/Natter

@MikeWang000000
Copy link
Collaborator

MikeWang000000 commented Feb 23, 2025

Natter 手搓实现了 UPnP 协议,但是目前在某些品牌路由器还存在兼容问题(头大)。
我觉得 NATMap 可以不必走这个老路,坑很大。

考虑下直接调用 upnpc 吧(miniupnp 的 client)。

https://manpages.debian.org/unstable/miniupnpc/upnpc.1.en.html

upnpc -i -a 192.168.1.1 12345 12345 tcp

↑ 这样就可以让路由器开放一个 12345 的 TCP 端口转发至 192.168.1.1:12345

不知道在通知脚本的时机调用是否能行,可能需要先调用 upnpc 再做 stun bind。@heiher

@aeeq
Copy link
Author

aeeq commented Feb 23, 2025

谢谢,我试试 Natter。

@heiher
Copy link
Owner

heiher commented Feb 24, 2025

Natter 手搓实现了 UPnP 协议,但是目前在某些品牌路由器还存在兼容问题(头大)。 我觉得 NATMap 可以不必走这个老路,坑很大。

考虑下直接调用 upnpc 吧(miniupnp 的 client)。

https://manpages.debian.org/unstable/miniupnpc/upnpc.1.en.html

upnpc -i -a 192.168.1.1 12345 12345 tcp

↑ 这样就可以让路由器开放一个 12345 的 TCP 端口转发至 192.168.1.1:12345

不知道在通知脚本的时机调用是否能行,可能需要先调用 upnpc 再做 stun bind。@heiher

如果UPnP建立映射时不会检索当前存在的会话并复用,应该是需要调整顺序的。找时间调调看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants