openvpn learn-address script to manage a hosts-like file
- intended to allow dnsmasq to resolve openvpn clients
- written for openwrt (busybox), but should work most anywhere
Everytime a new user connects to openvpn it will update openvpn hosts in /etc/hosts.openvpn-clients.
- Copy this script into /usb/bin.
- Set learn_address in your openvpn config to /usr/bin/ovpn-learnaddress
- Set script_security in your openvpn config to 2
- Include /etc/hosts.openvpn-clients in your domain server, like dnsmasq(addn-hosts=/etc/hosts.openvpn-clients)
Busybox uses lock instead of flock so choose the correct implementation
(command -v flock >/dev/null 2>&1 && false) ||
(command -v lock >/dev/null 2>&1 && (lock -u "$LOCKFILE"))
) 200>$((command -v flock >/dev/null 2>&1 && (echo $LOCKFILE)) ||
(command -v lock >/dev/null 2>&1 && (echo "/dev/null")))
Not sure what you mean by 'choose the correct implementation', but this code as written throws a syntax error.