史上最简单的NAT工具,利用的是Windows系统的防火墙的NAT功能实现的,不会有任何程序驻留,消耗资源极低,性能极高(内核级),把下面的内容保存为 nat.bat 即可,需要以管理员权限运行。
@echo off
echo 端口映射工具 v1.0
echo 版权所有(C) 2019,Kingron
if "%1"=="/?" (
echo.
echo 用法: nat [命令] [服务器端口] [远程IP] [远程端口]
echo 命令: l = 列出映射; a = 添加; d = 删除
echo.
echo 例子:
echo nat
echo nat /?
echo nat a 100 10.10.10.13 8000
echo nat d 100
)
if "%1"=="a" (
netsh firewall add portopening TCP %2 "端口映射 %2 => %3:%4" > nul
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=%2 connectaddress=%3 connectport=%4
)
if "%1"=="d" (
echo.
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=%2
netsh firewall delete portopening TCP %2 > nul
)
netsh interface portproxy show all
:end