Skip to content

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).

If you do not have a VPN on the router yet, set it up with the guide for your system: Keenetic / NetCraze, OpenWrt, Debian. In the keen-pbr web UI you pick the interface from a list. To see all interface names in the console, run 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.

If you have installed 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).

Tip: On Keenetic / NetCraze you can also open http://my.keenetic.net:12121/.

Create the VPN outbound

  1. Open Routing > Outbounds and click Add outbound.
  2. In Name, enter vpn.
  3. In Type, choose Interface.
  4. In Interface, pick your VPN interface name from the list.
  5. 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.
  6. 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

  1. Open Routing > Lists and click Add list.
  2. In Name, enter my_sites.
  3. In Source type, choose Domains / IPs.
  4. 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.
  5. Click Create list.

Add a routing rule

  1. Open Routing > Routing rules and click Add routing rule.
  2. Click Choose the first condition, choose Lists and select my_sites.
  3. In Route traffic through, choose vpn.
  4. 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

  1. 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.
  2. Open ifconfig.co and compare the IP address with the one an ordinary “my IP” website shows (for example wtfismyip.com). If the addresses differ, ifconfig.co goes through the VPN.

    Check from a computer or phone on your network, not with curl on the router itself: by default the router’s own traffic bypasses the rules. More: FAQ.

  3. To check from the command line, run this on the router:

bash
keen-pbr test-routing ifconfig.co

In the result table, the Expected Outbound and Actual Outbound columns should show vpn, and the last column should show OK.

All settings are described in Configuration; a ready-made example is in Full Reference Config. If something does not work, see Troubleshooting.