跳转至

CN-list分流与NAT配置

CN-list路由标记+nat

出口nat规则

/ip firewall nat
add action=masquerade chain=srcnat comment="WAN masquerade" out-interface=ether1
add action=src-nat chain=srcnat out-interface=gre-ct to-addresses=198.19.13.2

由于双lan,使用out.interface-list

/interface list
add comment="LAN interfaces subject to CN policy routing" name=Mark-LAN
/interface list member
add comment=lan interface=ether4 list=Mark-LAN
add comment=lan interface=ether5 list=Mark-LAN

针对any到wan

/ip firewall mangle
add chain=prerouting \
    in-interface-list=Mark-LAN \
    connection-state=new \
    connection-mark=no-mark \
    dst-address-type=!local \
    dst-address-list=List_ALL_China \
    action=mark-connection \
    new-connection-mark=cn-wan-conn \
    passthrough=yes \
    comment="CN: mark new connections"

/ip firewall mangle
add chain=prerouting \
    in-interface-list=Mark-LAN \
    connection-mark=cn-wan-conn \
    dst-address-type=!local \
    action=mark-routing \
    new-routing-mark=to-wan \
    passthrough=no \
    comment="CN: route marked connections via WAN"

针对本机流量,建议跟prerouting一致

/ip firewall mangle
add chain=output \
    connection-state=new \
    connection-mark=no-mark \
    dst-address-type=!local \
    dst-address-list=List_ALL_China \
    action=mark-connection \
    new-connection-mark=router-cn-wan-conn \
    passthrough=yes \
    comment="Router CN: mark new connections"

/ip firewall mangle
add chain=output \
    connection-mark=router-cn-wan-conn \
    dst-address-type=!local \
    action=mark-routing \
    new-routing-mark=to-wan \
    passthrough=no \
    comment="Router CN: route marked connections via WAN"