Custom Firewall setting preventing openvpn system.d service from creating tun/tap device

  • Greets,

    I am using the "/storage/.config/system.d/openvpn.service.example" as the basis for auto launching OpenVPN at boot.

    However, when used in conjunction with LibreELEC's Custom Firewall setting in Kodi, my "/storage/.config/iptables/rules.v4" configuration is preventing OpenVPN from creating its tunX/tapX device (i.e. it's missing from `ifconfig').

    My "/storage/.config/iptables/rules.v4" constitutes a VPN kill switch, only allowing traffic in and out of the VPN connection, or across the LAN:

    Oddly, if I flush iptables (`iptables -F'), I can restart OpenVPN (`systemctl restart openvpn.service"), which successfully creates the "tun0" device, and then run the exact same `iptables' commands to create the VPN kill switch. Both OpenVPN and the iptables VPN kill switch work as expected with this execution order.

    It seems that the iptables rules must not be implemented before executing OpenVPN?

    How can I ensure this at boot?

    Edited once, last by sunkai (November 22, 2020 at 12:05 AM).

  • I solved the order of execution by:

    1) Altering this section in my "openvpn.service":

    Code
    [Install]
    #WantedBy=kodi.target
    WantedBy=multi-user.target

    2) By scripting the desired modification of the iptables rules, and then using the "--up" option of `openvpn' to run the script (which executes scripts after the OpenVPN device tunX/tapX has been enabled).