miniupnp的客户端源代码包中自带咯一個用于测试的小程序upnp.c,在编译安装的时候也會一同被安装到系统中,可执行程序名为upnp,直接使用它便可以向网关申请启用某個端口的映射咯。
例如,将TCP的15245端口映射到192.168.1.104这台内网机器的15245端口:
bash-4.0# upnpc -a 192.168.1.104 15245 15245 tcp
upnpc : miniupnpc library test client. (c) 2006-2011 Thomas Bernard
Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
for more information.
List of UPNP devices found on the network :
desc: http://192.168.1.1:1900/igd.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found valid IGD : http://192.168.1.1:1900/ipc
Local LAN ip address : 192.168.1.104
ExternalIPAddress = 183.17.38.116
InternalIP:Port = 192.168.1.104:15245
external 183.17.38.116:15245 TCP is redirected to internal 192.168.1.104:15245 (duration=0)
bash-4.0#
感谢作者。
miniupnp的主页:http://miniupnp.free.fr/
HxLauncher: Launch Android applications by voice commands