Skip to content

Openwrt service to run public ip monitoring and running a script if there are any ip changes.

License

Notifications You must be signed in to change notification settings

calfeche13/public-ip-monitor-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Public IP Monitor Script

An OpenWrt service to monitor changes to the internet-facing public IP.

Check the LuCI App Public IP Monitor for the web interface manager.

Motivation

Public IP Monitor was created to update AWS security group rules, specifically for allowing traffic from my home network. My goal is to maintain a continuous VPN connection between my OpenWrt router and an AWS server without exposing the VPN port to the public. This would enable me to do various things, such as hosting Jellyfin on my personal computer and allowing me and a long-distance loved one to watch movies or series together.

Want to Support Me?

If you want me to continue making useful apps like this please support me through the links below :)

Buy Me A Coffee

Buy Me A Coffee

Setup

To install without building the app simply run the commands below.

# copy the contents of the root folder to othe root of openwrt
scp -r root/* root@<OpenWrt IP>:/

# execute the UCI defaults script to create the /etc/config/public_ip_monitor
ssh root@<OpenWrt IP> "sh /etc/uci-defaults/1301_public_ip_monitor"

# restart the public IPv4 monitor service
ssh root@<OpenWrt IP> "/etc/init.d/public_ip_monitor@ipv4 restart"

# restart the public IPv6 monitor service
ssh root@<OpenWrt IP> "/etc/init.d/public_ip_monitor@ipv6 restart"

The above command is useful during development. To actually build an IPK package for installation with opkg, refer to BUILDING.md

UCI Options

Monitoring Options

Enables/disables the monitoring of the public IP address.

Value is either 1 or 0.
Defaults is 0

public_ip_monitor.general.monitor_ipv4
public_ip_monitor.general.monitor_ipv6

Public IP Service

Options specifies the service where we can get the public IP address.

Value is of type hostname.
Default is 4.icanhazip.com for IPv4
Default is 6.icanhazip.com for IPv6

public_ip_monitor.general.ipv4_ip_service
public_ip_monitor.general.ipv6_ip_service

Check Interval

Below potioons specifies the interval of when to check for any public IP changes.

Value is in seconds and has a type of integer.
Default value is 30 seconds.

public_ip_monitor.general.ipv4_check_interval
public_ip_monitor.general.ipv6_check_interval

Onchange Script Location

The location of the script to run when a change of public IP is detected.

Note: IPv4 and IPv6 allows different scripts for flexibility but can make it so that both uses 1 script.

public_ip_monitor.general.ipv4_script_location
public_ip_monitor.general.ipv6_script_location

Current IP

This option holds the current public IP.

Note: Changing this will trigger the change detected.

public_ip_monitor.ipv4.current
public_ip_monitor.ipv6.current

History JSON

This is the path to the history.json file, where both IPv4 and IPv6 change histories are stored.

public_ip_monitor.general.history_location

About

Openwrt service to run public ip monitoring and running a script if there are any ip changes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published