You are not logged in.
Because my ip address changes very often and I wanted to know how often it changes I wanted to do one liner (to do from it an alias) to get ip address, time at which it was checked and write it to file, but only date and time is saved to file, not ip address.
How to write it all (from do to sleep, but not sleep)?
I was trying like this:
while true; do curl ipinfo.io/ip; printf ' '; date +%Y%m%d%H%M%S >> /tmp/ip; sleep 5m; done
while true; do curl ipinfo.io/ip; printf ' '; date +%Y%m%d%H%M%S &>> /tmp/ip; sleep 5m; done
The format should be:
ip adr (space) date & time - first check
ip adr (space) date & time - second check
...
ip adr (space) date & time - n-th check
EDIT:
I done it in that way:
while true; do echo "$(curl -s ipinfo.io/ip) $(date +%Y-%m-%d_%H:%M:%S)" >> /tmp/ip; sleep 5m; done &
Last edited by xerxes_ (2024-12-01 16:30:42)
Offline
Interesting: while using this script in background my IP address didn't change for few hours, but when I close it my IP address changed 2 times in about hour.
What can be said about this behavior? What can be said about my internet provider? It looks suspicious...
Offline
what's the actual type of your connection? dsl? coax? fiber? mobile?
also: does the ip you get match what your modem shows? could be carrier-grade nat with randomly changing exit-nodes (kinda like TORs auto re-route) for load balancing
the more interesting quesion is: why seem the ip stable with the script constantly query it from an external source but changes when this isn't the case any longer?
do you have some public endpoint you can establish a heartbeat tunnel to like some public ssh endpoint? using such and keep pinging the remote ever couple seconds should break the moment your ISP switches the endpoint - or maybe have some logic in place to prevent this when a long time session is detected (like a download of some big file taking some time - which could also be an option: https://ash-speed.hetzner.com/ )
Offline
You need to redirect curl ipinfo.io/ip; and the spacing to the file, too:
while true; do curl ipinfo.io/ip >> /tmp/ip; printf ' ' >> /tmp/ip; date +%Y%m%d%H%M%S >> /tmp/ip; sleep 5m; done
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
what's the actual type of your connection? dsl? coax? fiber? mobile?
This is vdsl2 modem/router through ethernet cable. It has set ipv6 address by internet provider, ipv4 is for this modem less important. And through this site I can't check ipv6 address.
the more interesting quesion is: why seem the ip stable with the script constantly query it from an external source but changes when this isn't the case any longer?
Yes, that's what I asking.
do you have some public endpoint you can establish a heartbeat tunnel to like some public ssh endpoint?
No.
@schard
Thanks, that also works, but I would add '-s' option to curl.
Offline