-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: run a script on interface up/down #1785
Comments
Agreed, this would be extremely useful! |
+1, would love to have this as an option. Does anyone have a work around for this scenario? |
Looks like this is currently only possible with a custom openvpn configuration file, set via the
(And just to be super clear) an example docker-compose.yml would be expected to include the following:
Since this only works with the custom provider set, I believe the specific feature request here would be to allow for supported (non-custom) providers to pass additional openvpn options. Perhaps this could be achieved via environment variables like I understand this probably adds a lot of complexity and many of these additional options may be overwritten or cause an otherwise invalid configuration. At the very least, it would be awesome to expose just the Idea for a temporary, hacky workaround: Maybe this is dumb, but I'm thinking a temporary workaround could be to mount a shell script (to our liking), and configure this to be run on a cron every hour (or whatever interval makes sense). If we take the OP's linked example, that endpoint does a rolling window rate limit of 1 call per hour. The shell script can be a "polite" by only making calls when deemed necessary, by checking if the public IP address has since changed. Example: #!/bin/bash
# File to store the last known public IP address
ip_file="/tmp/public_ip.txt"
# Command to fetch the current public IP address
current_ip=$(curl -s ifconfig.me/ip)
# Check if the IP has changed
if [ ! -f "$ip_file" ] || [ "$(cat "$ip_file")" != "$current_ip" ]; then
echo "$current_ip" > "$ip_file"
# Run your curl command here
curl -X POST https://example.com/update_ip --data "ip=$current_ip"
fi |
For wireguard, we just need to set PostUp/PostDown in the config. Given that the both openvpn and wireguard have support for this, I think a reasonable interface would be something along the lines of
|
Prioritizing this since it's kind of long overdued. Also it will be as a command to be cross-OS instead of a script path (but you could do This is also kind of needed to make sense of newly opened PR #2392 (more details why #2393 (reply in thread)) |
Up command is finally available: https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/vpn-port-forwarding.md#custom-port-forwarding-updown-command |
Enjoy! 🎉 |
Closed issues are NOT monitored, so commenting here is likely to be not seen. This is an automated comment setup because @qdm12 is the sole maintainer of this project |
What's the feature 🧐
Run a shell script when interface is up (or down)
Extra information and references
It can be useful to set a dynamic ip in a whitelist somewhere (like here)
The text was updated successfully, but these errors were encountered: