Keenetic
Requirements
- A Keenetic router with OPKG support.
- Entware.
- The Netfilter components, see below.
Install Entware
Newer models, with built-in storage
- Open the router's web interface.
- Open System settings.
- Turn on the OPKG package manager component.
Older models, with a USB drive
- Attach a USB drive to the router.
- Install Entware through the package manager.
The Keenetic help has the details.
Netfilter components
KeeneticOS does not ship every netfilter module b4 needs, so two components are turned on before b4 is installed. The components are available only under the admin account.
-
In the router's web interface, open System settings > Component options.
-
Search the components for
netfilter, and turn on Kernel modules for Netfilter if it is not on yet. -
Turn on Xtables-addons for Netfilter, which appears once the Netfilter modules are on.
-
Apply the changes, then reboot the router or reload the components.
-
Over SSH, install the iptables userspace:
opkg install iptables
Install b4
Over SSH on the router:
curl -fsSL https://raw.githubusercontent.com/DanielLavrushin/b4/main/install.sh | sh
The installer detects the architecture: mipsle_softfloat on older models (MT7621), arm64 on newer ones (aarch64).
Without Entware, b4 goes to /tmp, which is cleared on every reboot. Entware keeps b4 installed across reboots.
Service control
/opt/etc/init.d/S99b4 start
/opt/etc/init.d/S99b4 stop
/opt/etc/init.d/S99b4 restart
Paths
| What | Where |
|---|---|
| Binary | /opt/sbin/b4 |
| Configuration | /opt/etc/b4/b4.json |
| Service | /opt/etc/init.d/S99b4 |
Firewall rewrites
KeeneticOS rebuilds its firewall from time to time and removes b4's rules with it. The installer adds a hook that makes b4 restore them as soon as the rebuild ends. The log lines this leaves are explained under Router platforms.
DNS queries
On KeeneticOS with a kernel before 4.18 (4.14 before 4.14.173), b4 copies DNS queries instead of holding them. What that changes is described under Router platforms.
Troubleshooting
After the service starts, the error log shows whether anything failed:
cat /var/log/b4/errors.log
The errors and their fixes are listed under Router platforms. With no errors, the web interface is at the router's LAN address, on port 7000.