开发者

Debian send ip address on startup (sheevaplug)

开发者 https://www.devze.com 2022-12-19 09:55 出处:网络
I\'m having a sheevaplug with debian (default) installed on it. I would like to receive a mail with the ip-address of the sheevaplug, everytime it is restarted, AND everytime the ip address changes.

I'm having a sheevaplug with debian (default) installed on it.

I would like to receive a mail with the ip-address of the sheevaplug, everytime it is restarted, AND everytime the ip address changes.

I have no idea how to do this...

I realize I'm asking multiple things at once, so part of the solution is also ok:

  • how to write s开发者_JAVA百科omething that runs on startup?
  • how to send a mail?
  • how to detect a change in ip address?
  • how to retrieve the correct ip address? (ifconfig gives a lot of information I don't need)

Thanks!


If dyndns (see @taspeotis' answer) is not what you want, you can:

  • run commands once a network interface comes up by using the post-up hook of ifup (see man interfaces(8)
  • send email: echo "mail body" | mail -s subject recipient@foo.bar
  • detect changes of ip-address: this will probably happen if you use dhcp, if you're using dhclient you could use its /etc/dhcp3/dhclient-enter-hooks.d
  • get the correct ip address: ifconfig eth0 | grep "inet addr"


Do you want to know the IP address of the box so you can access it remotely? You may be better off with a DynDNS domain and client: http://www.dyndns.com/support/clients/#linux


For retrieve actual ip and mail you can do:

$ ifconfig eth0 | grep "inet addr" | mail -s subject yourmail@gmail.com
0

精彩评论

暂无评论...
验证码 换一张
取 消