Upnp
Jump to navigation
Jump to search
References
- MiniUPnP Project — home of upnpc
Install
- Download miniupnpc package
- untar it, compile and install it:
make
sudo make install
Usage
- List redirections:
upnpc -l
- Add a new redirections:
upnpc -a 129.19.3.106 9922 22 TCP # Let UPNP router forward connections on 9922 to 129.19.3.106:22 (TCP)
- Get public IP address (i.e. address of the ADSL router):
PUBLICIP=$(upnpc -l|perl -lne 'print for /ExternalIPAddress *= *([0-9]+.[0-9]+.[0-9]+.[0-9]+)/')
- Another solution using an external server:
PUBLICIP=$(wget http://automation.whatismyip.com/n09230945.asp -q -O -)