this post was submitted on 28 Jun 2023
20 points (100.0% liked)

Linux

47366 readers
887 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Maybe it's useful for somebody.
Checks ip and sends to your email.
Save as ipcheck.sh and put on /home/USER/
To check every hour, execute crontab -e and add this to the end:

0 * * * * sh ipcheck.sh

Here it goes:

#!/bin/sh

#########################
## uncomment and edit as needed
#########################
#mail_to="[email protected]"
#mail_from="[email protected]"
#user="[email protected]"
#pass="password123"
#host_params="--host=smtp.sapo.pt --port=587 --tls=on --tls-starttls=on --auth=on"

#########################
## do not edit lines bellow
#########################
ip_old=""
ip_new=""
if [ -f ip.txt ]; then ip_old="$(cat ip.txt)";  fi
ip_new="$(curl --connect-timeout 10 --max-time 10 --retry 3 --retry-delay 0 -s icanhazip.com)"

if [ "$ip_new" != "" ] && [ "$ip_new" != "$ip_old" ]
then
echo $ip_new > ip.txt
printf "To:$mail_to\nSubject: IP\n\nOld ip = $ip_old\nNew ip = $ip_new" | msmtp --timeout=10 -t --from=$mail_from --user=$user --passwordeval="echo '$pass'" $host_params
fi
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 year ago (2 children)

Pretty useful, definitely going to save this.

My home IP almost never changes, so I'd hate to pay for a static IP.

[–] [email protected] 5 points 1 year ago (1 children)

@Fubarberry @murkom noip.com has a free service I’ve used a bunch. Just run an app at home and select a domain. Some routers support the service too.

[–] [email protected] 2 points 1 year ago