RouterOS7 L2TP+Openwrt国内外分流
网络9个月前 (07-05)
为了实现手机和电脑不需要安装第三方软件的情况下,L2TP VPN连接至有公网ip的家用RouterOS路由器,方便回家,方便环游世界
下面示例中10.0.0.30为openwrt地址
新建L2TP地址池
/ip pool add name=L2TP-Pool ranges=172.20.1.2-172.20.1.10
配置ipsec
/ip ipsec proposal set [ find default=yes ] auth-algorithms=sha256,sha1
新建PPP模板和加密
/ppp profile add dns-server=10.0.0.30 local-address=172.20.1.1 name=l2tp-profile remote-address=L2TP-Pool use-encryption=yes /ppp secret add name=L2TP用户名 password=L2TP密码 profile=l2tp-profile service=l2tp
开启L2TP服务
/interface l2tp-server server set default-profile=l2tp-profile enabled=yes use-ipsec=required
新建路由表
/routing table add disabled=no fib name=l2tp
下载和导入国内IP段
/tool fetch url=http://www.iwik.org/ipcountry/mikrotik/CN /import file-name=CN
创建L2TP远端地址和局域网地址
/ip firewall address-list add address=172.20.1.2-172.20.1.10 list=l2tp-remote add address=10.0.0.0/27 list=CN
防火墙放行L2TP端口
/ip firewall filter add action=accept chain=input comment="allow L2TP VPN (ipsec-esp)" in-interface-list=WAN protocol=ipsec-esp add action=accept chain=input comment="allow L2TP VPN (500,4500,1701/udp)" dst-port=500,1701,4500 in-interface-list=WAN protocol=udp
防火墙做标记
/ip firewall mangle add action=mark-routing chain=prerouting dst-address-list=!CN dst-address-type=!local new-routing-mark=l2tp src-address-list=l2tp-remote
防火墙做伪装
/ip firewall nat add action=masquerade chain=srcnat comment=L2TP_NAT dst-address-list=!l2tp-remote src-address-list=l2tp-remote
添加路由表
/ip route add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=10.0.0.30 pref-src=0.0.0.0 routing-table=l2tp scope=30 suppress-hw-offload=no target-scope=10
本站所有文章均可随意转载,转载时请保留原文链接及作者。