Skip to content

Commit

Permalink
add example for ROSv7 routing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
povsister committed Oct 28, 2024
1 parent f2ed24f commit 37fd2e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ May 10 17:07:05 debian v2ray[195546]: 2024/05/10 17:07:05 192.168.88.192:44383 a

**⚠️:以下nftables配置包含了透明代理(TProxy)的配置,本教程中未直接列出透明代理的配置命令,请查阅上文自行进行透明代理的配置。**

**⚠️:注意透明代理中`OUTPUT Chain`的配置,其目的是拦截旁路由本身主动向外发出的流量并代理,但在一些特殊情况下会导致一些预期外的行为,包括但不限于:**
* **有公网IPv4的情况下,主路由暴露端口,并直接DNAT到旁路由的某一端口。会发现旁路由不响应任何来自公网IP的连接请求,其原因是响应报文被`OUTPUT Chain`拦截所致。**

**解决办法是:修改`OUTPUT Chain`规则,使其只拦截本机的UDP 53的DNS查询流量即可,但也会导致旁路由本身不在透明代理范畴内,不过基本没什么影响。有需要的可按照上文所述自行调整nftables规则,此处不再赘述。**

```shell
root@debian:~# nft list ruleset
table inet filter {
Expand Down Expand Up @@ -691,12 +696,18 @@ RouterId填写你主路由和旁路由通信的IP地址即可,图中仅供参
* **主路由创建策略路由规则**:来自于旁路由IP 192.168.87.2的数据包,仅查询路由表`side-anti-loop`
对应命令如下,其中`side-router`是我旁路由所在的网桥,`192.168.87.2`是我的旁路由IP,你可以视情况改成接口/你自己的旁路由IP。不要照抄。
ROSv6的对应命令如下,其中`side-router`是我旁路由所在的网桥,`192.168.87.2`是我的旁路由IP,你可以视情况改成接口/你自己的旁路由IP。不要照抄。
```shell
/ip route rule add src-address=192.168.87.2 interface=side-router action=lookup-only-in-table table=side-anti-loop
```
![SideRouter Policy Routing](/images/side-iprule.png)
⚠️:ROSv7系统的策略路由配置在`Routing -> Rules`菜单中,对应命令示例如下,注意不要照抄,`src-address``interface`要视情况改成你自己的旁路由IP和接口。
```shell
/routing rule add src-address=192.168.87.2 interface=side-router action=lookup-only-in-table table=side-anti-loop
```
![SideRouter Policy Routing](/images/rosv7-side-iprule.png)
至此,你应该已经完成了主路由的策略路由配置:所有来自于旁路由IP的数据包,将仅查询`side-anti-loop`这个路由表,
甚至包括V2Ray配置错误时(例如:错误的将应该代理的流量直连发出)也不会环路,从根本上避免了路由环路的产生。
Expand Down
Binary file added images/rosv7-side-iprule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 37fd2e7

Please sign in to comment.