UBNT EdgeOS 配置设备路由(interface-route)的方法
之前 EdgeOS PPTP VPN客户端配置 里,配置VPN后,需要按需配置路由。由于自用的路由下一跳IP不确定,所以用了 interface-route。 配置命令如下:
1 |
set protocols static interface-route 10.1.1.0/24 next-hop-interface pptpc0 |
按这种方式配置路由的麻烦在于,每次输入都需要把目标网段后边配上一个interface,万一哪天需要改这个interface,要不一个一个改,要不重新导入配置文件。 另外一个方法是用路由表+防火墙 路由表如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
root@ubnt# show protocols static table table 1 { description "route table via eth1: default internet access" interface-route 0.0.0.0/0 { next-hop-interface eth1 { } } } table 2 { description "route table via vtun0: openvpn access" interface-route 0.0.0.0/0 { next-hop-interface vtun0 { } } } [edit] |
防火墙里配置一个地址组,并配好modify规则
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
firewall { group { network-group FORBIDDEN_ZONE { network 8.8.0.0/16 network 8.25.0.0/16 } } modify AUTO_VPN { description "Auto route to vpn based on destination" enable-default-log rule 1 { action modify description "route to table 2" destination { group { network-group FORBIDDEN_ZONE } } log enable modify { table 2 } } rule 2 { action modify description "default route to table 1 " disable log enable modify { table 1 } } } } |
再把内外网口的防火墙规则改一下
1 |
set interfaces ethernet eth0 firewall in modify AUTO_VPN |
就行了。这里我的eth1连的外网,eth0是LAN。 不过这里有个case我没试过,直接配置interface-route的方法,如果目标网段的interface掉了,会回落到默认的出口上,不知道modify的效果如何。 EdgeOS 1.8b3下firewall的log记录在 /var/log/messages 里,可以看到请求命中了哪个规则。 Incoming search terms:EDGEOSedgeos设置edgeroute4 配置路由edgeos 设置dnsdrawna4ledgeos 设置EdgeOS iptableswhitex9gedge os 旁路由eaten4u4driveraccadditionqiydonkeyz67decideem6circusv4mchoiceo8abasicg1qarrangementi75apple7clanotherhm6Link to this post!