Use gh-pages as an API for the public IP (typically for dynamic IPs) of your home network, this repo is deployed without any real IP so what you'll see in gh-pages is {}
- Fork this repo/ use it as a template
git clone <YOUR-NEW-REPO>
to a machine in the network whose IP you want to have always accessible- Ensure you have python and git
- Deploy the script with one of the following (or other parallel alternatives you like):
python update-ip.py
to update oncenohup python update-ip.py &
this will send the output tonohup.out
nohup python update-ip.py > logs.txt &
this will send the output tologs.txt
- you can also use bg or tmux see this SO question for more ways
- Enable GH-pages
- Go to your repository settings
- Scroll to "GitHub Pages"
- Select source: "master branch /docs folder"
- (you can have your own custom domain) if not check https://YOUR-USER-NAME.github.io/my-public-ip-api/ to see something like
{"ipv4": "<YOUR-IPv4>", "ipv6": "<YOUR-IPv6>"}
- That is now an endpoint with your public IPs
Access servers and services in your home (or wherever) network even though they have dynamic IPs simply by querying your gh-pages endpoint and then use the IP to access them as if you had a static one.
By default, the script will check if your IP has changed every 10 seconds and update your gh-pages endpoint only if it has, if you want to increase this value, simply update the UPDATE_INTERVAL
in the update-ip.py in your own copy.
If you have privacy concerns, you can always make your copy private and change its name to a long and random sequence of chars like my-public-ip-api-nanananananananananananbatman