EdgeRouter Policy Based Routing Using DNSMASQ IPSET

之前用SNIProxy按域名区分流量,着实麻烦。尤其是后期发现路由表莫名其妙出问题。 EdgeRouter的Policy Based Routing(PBR)使用的是自带配置语法的firewall modify功能。 官方有两篇教程: EdgeRouter – Policy-based routing for destination port EdgeRouter – Policy-based routing (source address based) 第二篇文章顺带提了network-group。之前在配置VPN时,使用过network-group,还比较过使用firewall modify + network-group 与配置一堆interface-route的区别。 而,这里的network-group的实现,使用了netfilter的ipset。Man pages可以看这里,命令在edgerouter上也附带了。 dnsmasq支持 ‘–ipset‘ 参数,把对配置域名解析的IP存入到指定的ipset。具体细节可以看dnsmasq的文档。 dnsmasq配置的语法比较简单。

domain 部分参考 address 的语法。例如:

配置好所有自己需要的域名,重启dnsmasq即可。 ipset本身支持timeout,但是edge os的network-group不支持,所以在配置dnsmasq之前,最好创建一个新的network-group。 假定新建的ipset名叫 MY_SET,edge router的主要相关配置如下:

其他诸如配置 static table, interface firewall 可以参考最前边的文档。 Incoming search terms:edgemax Source Based … Continue reading “EdgeRouter Policy Based Routing Using DNSMASQ IPSET”

EdgeRouter Lite: Source Based Routing

I have 192.168.1.1/24 on my eth0 as LAN, VPN set up. For some cases, I want to visit some web site via VPN, I set up a socks 5 proxy. But socks 5 is not an option for iPhone & Android by default. So I added 192.168.10.1/24 to eth0 at the same time, traffic from … Continue reading “EdgeRouter Lite: Source Based Routing”