• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
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 553 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 Jul 6, 2017, 5:13 PM Jul 6, 2017, 5:05 PM

    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 Jul 8, 2017, 7:02 PM

      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
      2 out of 2
      • First post
        2/2
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
        This community forum collects and processes your personal information.
        consent.not_received