I would like to modify iptables after VPN connection. What is the best approach to achieve that ?
I already tried through systemd with a custom unit in NetworkManager dispatcher.d directory but it seems to only work at boot, not if VPN is stopped and restarted - if I wrote it right :
[Unit] Description=iptables setup Requires=nordvpnd.service After=nordvpn.service [Service] Type=simple ExecStart=/usr/local/bin/setup_iptables.sh [Install] WantedBy=multi-user.target
I could monitor tun0, if up and configured, parsing the result of :
ip address ls dev tun0
but that would mean delay between update. Ex. test every 5 sec. could mean at least 4 sec. when iptables is not configured as it should.
My last idea would be to run setup_iptables.sh every time /usr/bin/nordvpn is called, but how to achieve that ?