<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="ROS加VLAN ADSL多线PCC叠加设置">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2014-10-10 15:30<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:
ROS加VLAN ADSL多线PCC叠加设置


我们公司办公室里有两个ADSL共享上网，管理控制不方便再加上带宽利用率也不高，于是决定改用ROS做双线叠加，再加上网上很多人说两块网卡和一台可划VLAN的交换机就可以实现多线叠加，正好公司有多余的设备，正好用上。着手进行设置，设置完成后发现有且只有一条线能拨上号，一开始怀疑是VLAN划分有问题或者是交换机有问题，后来经过测试都没有问题，经baidu和google搜索发现在同一个网卡上划分的VLAN都是使用的那个网卡的MAC地址，电信限制了一个MAC地址只能用于一条ADSL拨号上网，当其中一条线路拨上以后这个MAC就不能再拨其它的帐号了，网上的前辈们说可以用桥来达到改变VLAN的MAC地址的目的，经过多方帮助以及研究，终于将ROS加VLANADSL多线PCC叠加设置成功


现在将处理过程记录在此方便以后查阅，上图麻烦，直接上脚本，而且是万能脚本，也很容易看懂。


1、划分VLAN、添加bridge并绑定多MAC、添加bridge端口



    :for i from=1 to=2 do={/interface vlan add arp=enabled comment=&quot;&quot; disabled=no\   

    
 interface=wan mtu=1500 name=(&quot;v1&quot;.$i) use-service-tag=no vlan-id=(&quot;1&quot;.$i)}   

    :for i from=1 to=2 do={/interface bridge add admin-mac=(&quot;00:A2:E0:F1:71:9&quot;.$i)\   

    
 ageing-time=5m arp=enabled auto-mac=no comment=&quot;&quot; disabled=no forward-delay=15s\   

     l2mtu=65535 max-message-age=20s mtu=1500 name=(&quot;ADSL-&quot;.$i)\   

    
 priority=0x8000 protocol-mode=none transmit-hold-count=6}   

    :for i from=1 to=2 do={/interface bridge port add bridge=(&quot;ADSL-&quot;.$i) comment=&quot;&quot; disabled=no\   

    
 edge=auto external-fdb=auto horizon=none interface=(&quot;v1&quot;.$i) path-cost=10 point-to-point=auto priority=0x80}  





对以上脚本做一个简单的解释


第一个带冒号的语句是在wan网口上划分VLAN，有几条线就把&ldquo;to&rdquo;后面的&ldquo;2&rdquo;改为你的实际线数，名称前缀为&ldquo;VL&rdquo;。


第二个带冒号的语句是添加桥并按顺序设置MAC，有几个VLAN就添加几个桥，名称前缀为&ldquo;ADSL-&rdquo;。


第三个带冒号的语句是将VLAN添加到对应的桥下面，比如VLAN11就添加到第一个桥下面


2、添加PPPOE接口



    :for i from=1 to=2 do={/interface pppoe-client add name=(&quot;pppoe-out&quot;.$i)\   

    
 interface=(&quot;ADSL-&quot;.$i) user=我是拨号帐号 password=我是拨号密码 add-default-route=no disabled=no}





这里要注意的是脚本里面的 &ldquo;user&rdquo;和&ldquo;password&rdquo;这两个的值要手动改一下，因为不可能每条ADSL的帐号和密码都一样，同上，&ldquo;to&rdquo;后面的数值可根据实际情况修改，有几条线就改成几,下面的脚本同此


3、设置多线叠加标记及PCC



    /ip firewall mangle   

    
add action=change-mss chain=forward comment=&quot;&quot; disabled=no new-mss=1400 protocol=tcp tcp-flags=syn   

    :for i from=1 to=2 do= {/ip firewall mangle add action=mark-connection chain=input comment=&quot;&quot; disabled=no\   

    
 in-interface=(&quot;pppoe-out&quot;.$i) new-connection-mark=(&quot;pppoe-out&quot;.$i) passthrough=yes}   

    :for i from=1 to=2 do= {/ip firewall mangle add action=mark-routing chain=output comment=&quot;&quot; connection-mark=(&quot;pppoe-out&quot;.$i)\   

    
 disabled=no new-routing-mark=(&quot;to_pppoe-out&quot;.$i) passthrough=yes}   

    :for i from=1 to=2 do= {/ip firewall mangle add action=mark-connection chain=prerouting comment=&quot;&quot; disabled=no dst-address-type=!local\   

    
 new-connection-mark=(&quot;pppoe-out&quot;.$i) passthrough=yes per-connection-classifier=(&quot;both-addresses:2/&quot;.($i-1)) src-address=192.168.0.0/24}   

    :for i from=1 to=2 do= {/ip firewall mangle add action=mark-routing chain=prerouting comment=&quot;&quot; connection-mark=(&quot;pppoe-out&quot;.$i)\   

    
 disabled=no new-routing-mark=(&quot;to_pppoe-out&quot;.$i) passthrough=yes src-address=192.168.0.0/24}  





4、添加路由和设置NAT



    :for i from=1 to=2 do= {/ip route add comment=(&quot;adsl&quot;.$i) disabled=no distance=1 dst-address=0.0.0.0/0\   

    
 gateway=(&quot;pppoe-out&quot;.$i) routing-mark=(&quot;to_pppoe-out&quot;.$i)}   

    :for i from=1 to=2 do= {/ip route add check-gateway=ping comment=(&quot;adsl&quot;.$i) disabled=no distance=10 dst-address=0.0.0.0/0\   

    
 gateway=(&quot;pppoe-out&quot;.$i)}   

    /ip firewall nat add action=masquerade chain=srcnat comment=&quot;NAT&quot; disabled=no out-interface=!lan  




经过以上的设置，我的ROS加VLAN的ADSL多线叠加设置就成功了，以上脚本可以说是做这个设置的万能脚本了，要改的地方非常少。下一步我将整理ADSL多线叠加下的端口映射和回流，想方便了解我的最新动态，请留言并订阅我的博客！

 


</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
