Skip to content

nbros652/ip-tracking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip-tracking

Track multiple system IPs with Syncthing, cron, and bash scripts


This serves as an alternative to DDNS. The idea here is to track changes in IP addresses across multiple systems, logging IP changes in separate files for each host. Then Syncthing or any other application that provides folder synchronization serves to maintain the IP log files that track IP history across the connected machines.

The basic components are:

  • get-ip.sh: This is a script that should be called by a cron job or similar task scheduler to fetch and log external IP changes. It can also be used in an interactive mode to test all of the urls in ip-fetch_server-list.txt or to check for compatibility of a new url that you are considering adding to ip-fetch_server-list.txt. To run in this mode, pass "check" as the first argument. This script attempts to use dig to determine the external IP. If that fails, it will also try using curl. At least one of these applications needs to be installed.

  • ip-fetch_server-list.txt: This file lists one web address per line (without leading http(s):// ). These are addresses to sites that return a caller's external IP. This list is used by get-ip.sh when attempting to discover a system's external IP using curl.

  • ip-to-clipboard.sh: This is a script that can be used to fetch the most recently recorded IP address for any system that tracks its own IP. It can be called with a IP log file (named as [hostname].ip) for incorporation in scripts to fetch the current IP address of a given system. It is a utilitarian script and is not required for basic usage.

  • [hostname].ip*: A file with a name fitting this pattern represents an IP log file for the system with a matching host name. Each line in such a file records a timestamp, the most recently discovered external IP address for that system, and the site used to determine the external IP. It is only updated when a change in the current external IP is detected by get-ip.sh.

  • error.log*: This file is modified anytime get-ip.sh has trouble fetching the external IP. Each line records a timestamp, the host name of the machine that experienced the issue, and a description of the issue.

    * These files are generated automatically by get-ip.sh when it is run.

Warning!

If you plan to use this on a system where someone might have access to modify any of your *.sh script files files, be careful! Any arbitrary modifications to script files will result in those modifications being run anytime those scripts are run on any of your hosts, including scheduled calls to run get-ip.sh. In my particular case, I use gpg2 to sign my scripts. That way, I can check the signature before running. If the signature doesn't match, I know the file was modifed, and I don't run them.

About

Track multiple system IPs with Syncthing, cron, and bash scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages