I have a VM in VirtualBox. Thanks to DHCP, it obtains a specific local IP. For example 192.168.18.16
I use upnpc (miniupnpc package) in order to create a redirection from internet to a specific port. For example, for FTP (port 21) I can create a redirection from 1621 external port to 21 port of the VM. I use cron with the line :
* * * * * upnpc -a 192.168.10.16 21 1621 TCP
My VM can be run in different network and obtains different IP such as 192.168.19.16, 192.168.30.16 ...
I don't want to modify manually the redirection depending of the networking where running. So I try in crontab -e :
* * * * * upnpc -a $(ifconfig eth0 | grep 'adr:' | cut -d: -f2 | awk '{ print $1}') 21 1621 TCP
But It's not working, why ? What could I do ?
Thx for your answers