MikroTik RouterOS 应用分享之七——单口多线上网(玩客云相关)
<div style="color: black; text-align: left; margin-bottom: 10px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 前些日子,有<span style="color: black;">伴侣</span>在玩迅雷的玩客云,<span style="color: black;">说到</span>了<span style="color: black;">每一个</span>玩客云设备前面都需要加装一台路由,<span style="color: black;">而后</span>对应一条线路(<span style="color: black;">思虑</span>专线接入成本,<span style="color: black;">因此</span>接入的<span style="color: black;">所有</span>是普通宽带需要PPPOE拨号),在<span style="color: black;">实质</span><span style="color: black;">运用</span>上面<span style="color: black;">增多</span>了不少的成本,<span style="color: black;">因此</span><span style="color: black;">期盼</span>进行一个网络优化。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这儿</span>就提一下<span style="color: black;">怎样</span>利用ROS系统自带的VRRP接口来实现单网口,多条线路上网(注:是实现10条以上线路的拨号上网)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> VRRP 其实是一个协议--虚拟路由冗余协议(Virtual Router Redundancy Protocol,简<span style="color: black;">叫作</span>VRRP)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 注:需要<span style="color: black;">仔细</span><span style="color: black;">认识</span>的<span style="color: black;">伴侣</span><span style="color: black;">能够</span>直接百度吧。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 本来这个是用来<span style="color: black;">做为</span>多路由互为备份时候的宕机冗余<span style="color: black;">运用</span>的,<span style="color: black;">然则</span><span style="color: black;">亦</span><span style="color: black;">能够</span>用来另用。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下面来看下这个组网,如图:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/56900004f7d70866b5d2~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=jVaXQzbvPS5d0YOQa1pRCf9xjsI%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">简单的做一个结构图</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">所有线路接入连接到交换机(注:某宝上面<span style="color: black;">有些</span>大厂的二手交换机成色都还是不错的,选全千兆普通的就行,<span style="color: black;">亦</span>就一台普通家用路由器的钱,<span style="color: black;">然则</span><span style="color: black;">能够</span>为你省下一二十台的路由的钱。)。ROS设备接入到交换机上,<span style="color: black;">举荐</span><span style="color: black;">运用</span>ROS的硬件设备,<span style="color: black;">选取</span>全千兆口的(注:<span style="color: black;">举荐</span>一个型号吧,MikroTik RB750Gr3 hEX,价格不高,大概350元以内,<span style="color: black;">倘若</span>线路接入是同一个运营商的前提下,拖带个五十个<span style="color: black;">上下</span>玩客云是不会有太大问题的,再往上的话<span style="color: black;">亦</span>不介意有人尝试下)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 接下来<span style="color: black;">咱们</span>进入配置</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">首要</span>是WAN口配置。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 首要任务是添加VRRP接口,<span style="color: black;">日前</span>wan口的网卡是ether1,将 vrrp 添加并且绑定到 ether1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">winbox设置如图:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/56910004da9ee5370837~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=VbxT2NdrfqgUKXXTdrtz1Y45LaE%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">有多少条线路就设置多少接口</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">经过</span>winbox添加vrrp 时候名<span style="color: black;">叫作</span>和ID号<span style="color: black;">不可</span>重复,关于优先级<span style="color: black;">这儿</span>说明下,255是优先级最高,<span style="color: black;">这儿</span>不需要修改。vrrp 的数量<span style="color: black;">通常</span>不介意超过50,之前在调试过程中<span style="color: black;">发掘</span><span style="color: black;">倘若</span>超过太多会<span style="color: black;">显现</span>有些线路<span style="color: black;">不可</span>正常拨号的现象,需要手工操作<span style="color: black;">或</span>利用脚本触发进行<span style="color: black;">起步</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">批量添加的话就需要用到脚本命令,如下:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> # for i from=1 to=50 do={/interface vrrp add vrid=$i name=("vrrp".$i) arp=enabled disabled=no interface=ether1 }</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 注:<span style="color: black;">这儿</span>的 “i” 是变量。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">添加完成以后,会<span style="color: black;">发掘</span>所有的vrrp<span style="color: black;">表示</span>都是红色的,<span style="color: black;">这儿</span>需要给所有的vrrp和vrrp绑定的网卡都需要配置IP<span style="color: black;">位置</span>。这个<span style="color: black;">位置</span>随便填写<span style="color: black;">就可</span>,<span style="color: black;">倘若</span>是拨号线路,<span style="color: black;">位置</span>不影响网络。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">运用</span>脚本快速添加IP<span style="color: black;">位置</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">#for ad from=1 to=50 do={/ip address add address=("192.168.168.".$ad) netmask=255.255.255.0 interface=("vrrp".$ad) disabled=no }</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 在vrrp上<span style="color: black;">创立</span>pppoe拨号,<span style="color: black;">每一个</span>拨号账号对应一个vrrp,如图:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p6-sign.toutiaoimg.com/569500022bf246d89f89~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=0PETyiC5Z%2BXzkWgDQsoWOx5sk9M%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在vrrp接口上面<span style="color: black;">创立</span>pppoe拨号</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p26-sign.toutiaoimg.com/569500022cf345d5ccd7~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=iHFMsEE0Pf8Nzk3pHV0y2pgYcoY%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">pppoe拨号配置</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上图中红色框内三项不要勾选,后面<span style="color: black;">咱们</span><span style="color: black;">运用</span>脚本进行提取<span style="color: black;">而后</span>自动添加。(注,pppoe-out线路编号<span style="color: black;">必定</span>要连贯,后续的脚本需要<span style="color: black;">运用</span>到。)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">由于</span>要<span style="color: black;">创立</span>多条路由规则,<span style="color: black;">因此</span>在设置pppoe拨号的时候<span style="color: black;">无</span><span style="color: black;">运用</span>自动添加网关,<span style="color: black;">由于</span>pppoe拨号会<span style="color: black;">显现</span>网关变动的<span style="color: black;">状况</span>,这就需要做到自动更新。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>配置默认路由,有多少个pppoe拨号就设置多少条,<span style="color: black;">而后</span>对路由线路进行编号,如图:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/568f00053cb415e613ff~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=TcWv370lZCDnUhFV3TsTpq32%2Fqg%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">路由添加</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> “routing mark” 对应每条线路进行标号。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 批量添加脚本如下:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">#:for r from=1 to=50 do={/ip route add gateway=("pppoe-out".$r) check-gateway=ping distance=$r routing-mark=("x".$r) disabled=no}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 添加完成以后,还需要<span style="color: black;">增多</span>一条<span style="color: black;">按时</span>取网关<span style="color: black;">位置</span>和修改路由网关<span style="color: black;">位置</span>的脚本。如图:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/56950002676c726a6359~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=8uoroaH2ios4lLxy6riahCBALNI%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">网关自动更新-1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 写好脚本以后,在计划任务中添加对应的任务,<span style="color: black;">意见</span>每十秒检测一次。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/56940002e1ebc2cf972a~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=XF%2FGLg%2BqH0ML4moRZF88lLjzZDI%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">计划任务添加</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 到<span style="color: black;">这儿</span>,单网口多线拨号<span style="color: black;">已然</span>基本完成,路由可能正常连接这些线路的网络。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">配置路由和策略。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 路由配置,</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/56950002722f67247c23~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=t5jSA9GB%2FBZs%2FgxaXeNH2mZDq0s%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">位置</span>伪装转发配置</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 红色框中在这种多线拨号上网时候留空就<span style="color: black;">能够</span>,<span style="color: black;">由于</span>需要对所有的终端数据报文进行标记,<span style="color: black;">而后</span><span style="color: black;">按照</span>标记确定从哪条线路上网。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 对数据包进行标记:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/56940002ef2c60f71fed~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=SLq2JUwetXlfUj5StRXKcqXYbio%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">数据包标记,制定路由出口线路</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 在数据报文进行标记完成以后,还需要在路由设置里面针对这些数据包的路由表。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/568f00057426f691f3e2~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1725646918&x-signature=D22dC%2FMzjgM968oRyABgHzCe2tg%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">配置</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 至此,单网口多线拨号上网完成。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这儿</span>的VRRP方式,<span style="color: black;">经过</span>修改路由策略,和路由报文标记策略,<span style="color: black;">亦</span>可做多运营商的多线策略路由,<span style="color: black;">包含</span>多线路叠加。</p>
</div>
论坛是一个舞台,让我们在这里尽情的释放自己。 感谢楼主的分享!我学到了很多。
页:
[1]