进行以下设置:
- Mikrotik rb2011uias-2hnd-in 路由器操作系统 6.36.2
- 配置了 10.0.141.0/24 子网的 OpenVPN 客户端
我需要通过 VPN 路由地址列表。我读到https://superuser.com/questions/999196/mikrotik-and-vpn-for-specific-web-sites-only并配置 NAT:
[damamaty@dw-router] > /ip firewall nat print
0 ;;; defconf: masquerade
chain=srcnat action=masquerade out-interface=eth1-wan log=no log-prefix=""
1 ;;; OpenVPN
chain=srcnat action=masquerade out-interface=openvpn-client log=no log-prefix=""
2 ;;; Block (redirect) third-party dns
chain=dstnat action=redirect to-ports=53 protocol=udp dst-address-type=!local dst-port=53 log=no log-prefix=""
3 chain=dstnat action=redirect to-ports=53 protocol=tcp dst-address-type=!local dst-port=53
曼格尔:
[damamaty@dw-router] > /ip firewall mangle print
Flags: X - disabled, I - invalid, D - dynamic
0 D ;;; special dummy rule to show fasttrack counters
chain=prerouting
1 D ;;; special dummy rule to show fasttrack counters
chain=forward
2 D ;;; special dummy rule to show fasttrack counters
chain=postrouting
3 ;;; OpenVPN
chain=prerouting action=mark-routing new-routing-mark=rkn passthrough=yes dst-address-list=rkn log=no log-prefix=""
地址列表:
[damamaty@dw-router] > /ip firewall address-list print
0 rkn 178.63.151.224
...
以及带有路由标记“rkn”的路由(与 mangle 中的相同):
[damamaty@dw-router] > /ip route print
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 A S ;;; OpenVPN
0.0.0.0/0 10.0.141.1 1
1 ADS 0.0.0.0/0 37.194.203.1 1
2 ADC 10.0.141.1/32 10.0.141.6 openvpn-client 0
3 ADC 37.194.203.0/24 37.194.203.129 eth1-wan 0
4 ADC 192.168.1.0/24 192.168.1.1 br1-lan 0
但它不起作用——我无法在浏览器中打开地址。Traceroute 显示以下内容:
$ traceroute rutracker.org
traceroute to rutracker.org (195.82.146.214), 64 hops max, 52 byte packets
1 router (192.168.1.1) 1.001 ms 0.721 ms 0.715 ms
2 10.0.141.1 (10.0.141.1) 98.930 ms 99.776 ms 99.436 ms
3 * * *
4 108.61.99.1 (108.61.99.1) 101.532 ms 100.833 ms 98.721 ms
5 * * *
6 * * *
7 * * *
...
如果我将路由 (0.0.0.0/0 -> 10.0.141.1 [mark="rkn"]) 替换为一条简单路由 (178.63.151.224 -> 10.0.141.1) - 它可以正常工作(通过 vpn)。为什么 mangling 的方式不起作用?
答案1
这种标记非常适合要路由的源地址列表;对于您的情况(基于目的地的标记路线):使用和mangle rule
链复制。并测试它是否有效。Forward
Postrouting
您也可以用
ip route rule
这个。