适用于 macOS 的 VPN 杀死开关
VPN kill switch for macOS. Blocks all outgoing traffic when the VPN connection drops, preventing your real IP from leaking.
When enabled, killswitch loads pf firewall rules that only allow traffic through the VPN tunnel. If the VPN disconnects, the tunnel interface disappears but the firewall rules remain — blocking all internet traffic until the VPN reconnects or the kill switch is disabled.
Rules are written to /tmp/killswitch.pf.conf and loaded with pfctl.
The system default /etc/pf.conf is never modified.
Show network interfaces, public IP, and detected VPN peer:
$ killswitchEnable the kill switch (requires root):
$ sudo killswitch -eDisable and restore default firewall rules:
$ sudo killswitch -dPrint the firewall rules without applying them:
$ killswitch --print| Flag | Description |
|---|---|
--leak |
Allow ICMP (ping) and DNS requests outside the VPN |
--local |
Allow local network traffic |
--ipv4 |
Manually specify the VPN peer IP (auto-detected if omitted) |
-v, -vv |
Verbose / debug output |
Enable with DNS leak and local network access:
$ sudo killswitch -e --leak --localSpecify the VPN peer IP manually:
$ sudo killswitch -e --ipv4 203.0.113.1Preview rules in debug mode:
$ killswitch --print --leak -vvThe VPN gateway IP is auto-detected using multiple methods (in order):
UGSH/UGSc flagsIf auto-detection fails, use --ipv4 to specify the VPN peer IP manually.
Requires Rust:
$ cargo build --release
$ sudo cp target/release/killswitch /usr/local/bin/$ just test # format check + clippy + tests
$ just fmt # check formatting
$ just clippy # lint all targets暂无开放 Issues,或尚未同步最近议题。