公网地址那么少,都是内网的机器,可是有的时候还是需要端口映射的,但是一个一个打开网页去弄还真是有点麻烦,于是想到了upnp。
ubuntu
apt-get install -y miniupnc
命令
upnpc -a @H_404_16@192.168.@H_404_16@31.176 @H_404_16@9000 @H_404_16@9000 TCP
成功后的结果是
ops@ops-MS-@H_404_16@7732:~$ upnpc -a @H_404_16@192.168@H_404_16@.31@H_404_16@.176 @H_404_16@9000 @H_404_16@9000 TCP
upnpc : miniupnpc library test client. (c) @H_404_16@2005-@H_404_16@2014 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.31.1:5351/rootDesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:@H_404_16@1
Found valid IGD : http://192.168.31.1:5351/ctl/IPConn
Local LAN ip address : @H_404_16@192.168@H_404_16@.31@H_404_16@.176
ExternalIPAddress = xxxxx
InternalIP:Port = @H_404_16@192.168@H_404_16@.31@H_404_16@.176:@H_404_16@9000
external xxxxx:@H_404_16@9000 TCP is redirected to internal @H_404_16@192.168@H_404_16@.31@H_404_16@.176:@H_404_16@9000 (duration=@H_404_16@0)
记得要打开路由器的upnp功能
之前没有打开,就会报错
我用的是小米的无线无线路由器。