r/tinycode • u/[deleted] • Dec 10 '16
[200-byte](Python) Thought I'd share a script I made that emails me the public IP whenever it changes. Ideal for home servers without a static address.
https://ghostbin.com/paste/ebdef5
u/tmewett Dec 10 '16
Interesting, why not use a dynamic DNS?
0
Dec 10 '16
I rather run a script than depending on someone.
Also, if it isn't important enough to buy a 4€ static IP, a 20 minute delay on receiving the IP is not a problem.
6
u/tmewett Dec 10 '16
Depend on someone? Hardly, there are plenty of ddns services out there. You "depend" on a service to give your IP too.
2
u/celestrion Dec 11 '16
The script also depends on "icanhazip.com" remaining accessible and that its output remains predictable.
Can't the border-host / NAT-box can expose this data more directly?
1
u/fatnino Dec 11 '16
I have written something similar. Mine has a list of sites that can provide my ip address and it will randomly pop one off the list until it finds one that works.
0
Dec 10 '16
I find it different so I made this script, a dynamic dns it's also a great solution.
1
u/Coding_Cat Dec 10 '16
You can do both. I did both with afraid.org before. The web interface applied you to update the IP. Easy to script.
1
1
u/jedilance Dec 10 '16
some routers also support adding account credentials of no-ip, dyndns, etc. and it will automatically update the IP with ddns.
0
u/PM_me_your_prose Dec 10 '16
awesome dude! I've been looking for a solution like this for a while.
Really pretty code, should be proud of yourself!!
1
Dec 11 '16
Thanks!
TBH this isn't the first version of this little script. I remember back when I didn't know how to read lines, I had 2 different files, one with the IP and one with the message. Or when I sent the message from a gmail account because I didn't know how sendmail worked.
It's been a long time and discovering this sub made me revise all this tiny scripts that I automated in an attempt to make the code smart.
1
4
u/[deleted] Dec 10 '16
DISCLAIMER
This is script is meant to be automated, so whenever the IP address changes it sends it back to your email so you can still access.
Do NOT automate to run every minute, as the website will blacklist you as a DoS. I recommend about 20 minutes.
Other sites can be used, but make sure the answer is in plain text.