RKN ip block list routes to vpn by BGP

RKN ip block list routes to vpn by BGP

We will assume that the VPN that allows you to add routes on the fly is already configured.


  1. install bird (BGP daemon)

opkg update
opkg install bird2 bird2c

  1. clean default bird config

> /etc/bird.conf

  1. write new config /etc/bird.conf

log syslog all;
log stderr all;

router id $IP;

protocol device {
scan time 300;

protocol kernel kernel_routes {
scan time 60;
ipv4 {
import none;
export all;

protocol bgp antifilter {
ipv4 {
import filter {
#gw = $IP_GW;
ifname = "$INTERFACE";
export none;
local as $ASN;
neighbor as 65432;
hold time 240;

where is:

$IP - your white ip from WAN interface

$INTERFACE - your VPN interface name

$IP_GW - ip your remote gateway in VPN network

$ASN - autonomous system number (any number in the range 64512-65543 except 65432).

You must choose between $INTERFACE and $IP_GW. the rest should either be commented out with the # symbol or removed from the config.

  1. restart bird

service bird restart
# or
/etc/init.d/bird restart

  1. check bird work

birdc show protocols all antifilter
# or only routes count (must be greater than 0)
birdc show protocols all antifilter | grep 'Routes:'


If your ISP blocks BGP or blocks the ip ( of the antifilter service, you can set up a static route to its ip in your VPN settings.

example for wireguard:

  1. in config file /etc/config/network

config route 'for_antifilter'
option target ''
option netmask ''
option interface '$INTERFACE'
  1. or in UCI cmd utility

uci set network.for_antifilter=route
uci set network.for_antifilter.target=''
uci set network.for_antifilter.netmask=''
uci set network.for_antifilter.interface='$INTERFACE'
uci commit

And restart network or reboot:

# restart network
service network restart
# reboot

Instructions taken from here.