Quick Start
After this guide, one test site opens through your VPN and the rest of your traffic goes the usual way. You need a VPN interface that already exists on the router (for example tun0 or wg0).
ip addr: the VPN interface is the one with an address from your VPN network.If you installed the full package, start with the Web UI. If you have keen-pbr-headless or prefer editing files, use the JSON tab.
Setup takes three steps:
graph LR;
classDef default font-size:16pt;
A["1. Add outbounds"]
B["`2. Add lists
(optional)`"]
C["3. Add routing rules"]
A==>B;
B==>C;
Three terms you will meet below:
- outbound is a channel traffic goes through: a VPN interface, your normal provider connection, or a block;
- list is a set of domains and IP addresses, for example “sites that must go through the VPN”;
- routing rule links the two: “traffic from this list goes to this outbound”.
The default config already has the outbounds wan (the normal internet connection through your provider), block and direct_local, plus the list local_networks with a rule that keeps your home network local. You only need to create the vpn outbound, one list and one rule.
keen-pbr-headless, see JSON configuration method.
Open the Web UI
Open http://<router-ip>:12121/ in your browser (replace <router-ip> with your router IP address).
Create the VPN outbound
- Open Routing > Outbounds and click Add outbound.
- In Name, enter
vpn. - In Type, choose Interface.
- In Interface, pick your VPN interface name from the list.
- Leave Default gateway IPv4 and Default gateway IPv6 empty. A gateway is the address of the next router on the path; VPN tunnels usually do not need one. If you fill in only one of the fields, traffic of the other kind (IPv4 or IPv6) will not go through this outbound.
- Click Create outbound.
The wan outbound already exists: it is the normal internet connection through your provider (routing table 254). If it is missing, create it: Type > Routing table, Table ID 254.
Create a test list
- Open Routing > Lists and click Add list.
- In Name, enter
my_sites. - In Source type, choose Domains / IPs.
- In Domains, enter
ifconfig.co. For a real service like YouTube one domain is not enough: use a ready-made list, see Remote URL list. - Click Create list.
Add a routing rule
- Open Routing > Routing rules and click Add routing rule.
- Click Choose the first condition, choose Lists and select
my_sites. - In Route traffic through, choose
vpn. - Click Create rule.
The new rule appears below the local_networks rule. Rules are checked from top to bottom, and the first matching rule wins.
Apply the changes
A banner appears at the top of the page: “Configuration was changed. Save it to disk to apply it.” Click Apply and wait until the banner disappears.
Check the result
-
Clear the DNS cache on your device:
- On Windows, open Command Prompt and run
ipconfig /flushdns. - On Linux, open a terminal and run
sudo resolvectl flush-caches. - On mobile devices, reconnect to Wi-Fi.
- On Windows, open Command Prompt and run
-
Open
ifconfig.coand compare the IP address with the one an ordinary “my IP” website shows (for examplewtfismyip.com). If the addresses differ,ifconfig.cogoes through the VPN.Check from a computer or phone on your network, not with
curlon the router itself: by default the router’s own traffic bypasses the rules. More: FAQ. -
To check from the command line, run this on the router:
keen-pbr test-routing ifconfig.coIn the result table, the Expected Outbound and Actual Outbound columns should show vpn, and the last column should show OK.