Upnp: Difference between revisions
Jump to navigation
Jump to search
(Created page with '== References == * [http://miniupnp.free.fr/ MiniUPnP Project] — home of ''upnpc'' == Install == * Download [http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.5.…') |
(→Usage) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
* Add a new redirections: |
* Add a new redirections: |
||
<source lang=bash> |
<source lang=bash> |
||
upnpc -a 129.19.3.106 |
upnpc -a 129.19.3.106 22 9922 TCP # Let UPNP router forward connections on 9922 to 129.19.3.106:22 (TCP) |
||
</source> |
|||
* Get public IP address (i.e. address of the ADSL router): |
|||
<source lang="bash"> |
|||
PUBLICIP=$(upnpc -l|perl -lne 'print for /ExternalIPAddress *= *([0-9]+.[0-9]+.[0-9]+.[0-9]+)/') |
|||
</source> |
|||
:Another solution using an external server: |
|||
<source lang="bash"> |
|||
PUBLICIP=$(wget http://automation.whatismyip.com/n09230945.asp -q -O -) |
|||
</source> |
|||
:As a sidenote, to get local IP address: |
|||
<source lang="bash"> |
|||
IPETH0=$(ifconfig eth0 | perl -lne 'print for /inet[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/') # eth0 |
|||
IPWLAN0IP=$(ifconfig wlan0 | perl -lne 'print for /inet[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/') # wlan0 |
|||
IPETH0=$(ip addr show eth0 | perl -lne 'print for /inet[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/') # Other solution using command ip |
|||
</source> |
</source> |
Latest revision as of 21:16, 23 July 2011
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 22 9922 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 -)
- As a sidenote, to get local IP address:
IPETH0=$(ifconfig eth0 | perl -lne 'print for /inet[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/') # eth0
IPWLAN0IP=$(ifconfig wlan0 | perl -lne 'print for /inet[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/') # wlan0
IPETH0=$(ip addr show eth0 | perl -lne 'print for /inet[^0-9]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/') # Other solution using command ip