ifconfig
does not show output, probably because by the time it runs, the networking setup is not fully completed. Furthermore, there are not 100% guarantees the dynamic IP address won't change over the server uptime.
If using dhclient
, move the script to the directory /etc/dhcp/dhclient-exit-hooks.d
, so it executes after getting an IP address via DHCP. Debian usually populates this directory; if it does not exist it might have to be created.
The script can be changed for sending the IP address at boot, and every time it changes. Be aware that depending in your IP address DHCP lease lifetime, you might or might not be interested in copying it everytime.
If in an ISP/Internet environment, it might be also (more) interesting to use a dynamic DNS service.
Please do see this for more details Better method for acting on IP address change from the ISP?
and
http://manpages.ubuntu.com/manpages/wily/man8/dhclient-script.8.html
ifconfig -a
orip all show
– Archemar May 26 '16 at 07:48/tmp/myip
? – Julie Pelletier May 26 '16 at 07:50