You are not logged in.

#1 2011-08-14 18:06:48

pappbox
Member
From: Norway
Registered: 2008-01-04
Posts: 42

Send internet IP at boot

Hi.

I am going away for one year and I want to be able to upload backup files to my linux box while I am gone.

BIOS wil boot the machine in the evenings and I will find a script or something to shut it off after two hours every day.

SSH is taken care of.


The thing is. I need to get the internet IP sendt to me by mail everytime the system boots, and I don't know how to do that.

I have been googeling some and found out about /etc/rc.d/rc.local

I tried using this script I found from another forum:

"ip addr | grep "inet " | grep -v "lo\$\|virbr0" | cut --delim=" " -f6 | cut -d/ -f1 | mailx -s "$(hostname) IP" someone@somewhere"

but it reports   

/usr/sbin/sendmail: Ingen slik fil eller filkatalog "/home/<user>/dead.letter" 9/236 . . . message not sent.

Thanks for your help!

Last edited by pappbox (2011-08-14 18:09:05)

Offline

#2 2011-08-14 18:18:48

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Send internet IP at boot

You need an MTA capable of relaying to another smtp server to send email. You could use something as simple as msmtp which would leverage an account you have with a provider like gmail.

Also... your pipeline makes me cry:

ip a show dev MYINTERFACE | awk '$1 == "inet" { split($2, a, "/"); print a[1]; }' | <mta>

Replace MYINTERFACE accordingly.

Offline

#3 2011-08-14 18:44:26

pappbox
Member
From: Norway
Registered: 2008-01-04
Posts: 42

Re: Send internet IP at boot

Thanks for helping.

I just got to the realisation that the IP i need is the one from my internet provider. Not the one my broadband router is giving.

Can you think of any way to implement that in the mail that is going out?

Offline

#4 2011-08-14 19:23:46

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Send internet IP at boot

Perhaps use the output from curl -s ifconfig.me.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#5 2011-08-14 19:28:16

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: Send internet IP at boot

Wrote a script for just this purpose.  In the AUR: http://aur.archlinux.org/packages.php?ID=37553

Offline

#6 2011-08-14 19:28:48

pappbox
Member
From: Norway
Registered: 2008-01-04
Posts: 42

Re: Send internet IP at boot

Lovely! Thanks a lot!

Think I am good with google now to set this up.

Offline

#7 2011-08-14 20:14:35

pappbox
Member
From: Norway
Registered: 2008-01-04
Posts: 42

Re: Send internet IP at boot

I have installed your script now. Is there a way to test it before my ISP changes my IP address?

Offline

#8 2011-08-14 21:40:42

pappbox
Member
From: Norway
Registered: 2008-01-04
Posts: 42

Re: Send internet IP at boot

The best would actually be if I could get the system to send me a email everytime it boots. so I can know that it is still alive and up and running.

I think I going to try this first. To run a simple sendEmail command everytime the pc powers on.

But how can I make the simpleEmail script print the output of

curl -s ifconfig.me

in the email body?

Cheers!

Offline

#9 2011-08-14 23:05:00

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: Send internet IP at boot

Surely DynDNS + ddclient would be simplest?

Offline

#10 2011-08-14 23:54:13

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: Send internet IP at boot

pappbox wrote:

I have installed your script now. Is there a way to test it before my ISP changes my IP address?

Did you take a look at the code?  Just change the contents of /usr/bin/checkip.sh ?

Just change the IP addy in ~/.oldip and run the script again.

Offline

Board footer

Powered by FluxBB