Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    OpenVPN killswitch, problem with pfctl

    Scheduled Pinned Locked Moved OpenVPN
    2 Posts 2 Posters 582 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      xl
      last edited by

      Hello!

      I created simple killswitch for openvpn: when client is connected it allow internet connection for LAN users, when client is disconnected access is denied.
      I got a strange problem with state killing. When script work from openvpn it can't kill all states, so some LAN connection that active still work when VPN client is disconnected.

      How it works:
      In OpenVPN server Custom options:
      script-security 3 system;
      client-connect /usr/local/sbin/up.sh;
      client-disconnect /usr/local/sbin/down.sh;

      up.sh:
      #!/bin/sh

      /usr/local/bin/easyrule unblock lan 192.168.56.0/24
      /sbin/pfctl -k 192.168.56.0/24

      down.sh:
      #!/bin/sh

      /usr/local/bin/easyrule block lan 192.168.56.0/24
      /sbin/pfctl -k 0.0.0.0/0
      /sbin/pfctl -k 192.168.56.0/24

      It work as needed, but pfctl command is works really strange from openvpn. When I run up/down scripts from console it kill all states without any problem. When VPN client is disconnected some states remains intact (I know that: pfctl command is executed, because I got disconnected from SSH, but ping on test machine is going without interruptions).

      What I'm missing here? :)

      1 Reply Last reply Reply Quote 0
      • R
        Ryu945
        last edited by

        What I use as a kill switch is a firewall rule that blocks all traffic on the WAN interface.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.