This translation is older than the original page and might be outdated. See what has changed.

PBR app

PBR app(文档) 提供一种先进的基于策略的路由解决方案。

安装后启用PBR

# 安装PBR
opkg update
opkg install pbr
 
# 启用 PBR
uci set pbr.config.enabled="1"
uci commit pbr
service pbr restart

如果您想通过网页界面管理PBR设置。请安装必要的软件包。

# Install packages
opkg update
opkg install luci-app-pbr
service rpcd restart

支持像OpenVPN这样的非托管协议。

# Support OpenVPN
uci add_list pbr.config.supported_interface="tun*"
uci commit pbr
service pbr restart

使用Tailscale时,请创建数字优先级值较低的规则。请注意,Tailscale(配置了出口节点后)会将自身设置为默认值,但这可能不会在PBR 网页界面中体现(例如,PBR 网页界面可能仍显示WAN为默认路由)。

# Support Tailscale
uci set pbr.config.wan_ip_rules_priority="1000"
uci commit pbr
service pbr restart

在VPN客户端配置文件中禁用网关重定向 。 将 LAN 192.168.1.0/24 路由到 VPN。

# Route LAN to VPN
uci add pbr policy
uci set pbr.@policy[-1].src_addr="192.168.1.0/24"
uci set pbr.@policy[-1].interface="vpn"
uci commit pbr
service pbr restart

将WAN端口转发到运行在“192.168.1.2”上的Web服务器。将此策略安排在更通用的策略之上。

# Forward WAN port
uci add pbr policy
uci set pbr.@policy[-1].src_addr="192.168.1.2"
uci set pbr.@policy[-1].src_port="443"
uci set pbr.@policy[-1].proto="tcp"
uci set pbr.@policy[-1].interface="wan"
uci reorder pbr.@policy[-1]="1"
uci commit pbr
service pbr restart

优先处理本地子网“192.168.1.0/24”和“192.168.3.0/24”之间的路由。将此策略置于所有其他策略之上。

# Prioritize local subnets
uci set pbr.config.webui_show_ignore_target="1"
uci add pbr policy
uci set pbr.@policy[-1].dest_addr="192.168.1.0/24 192.168.3.0/24"
uci set pbr.@policy[-1].interface="ignore"
uci reorder pbr.@policy[-1]="1"
uci commit pbr
service pbr restart
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2025/09/09 02:02
  • by starsfall