实验环境
虚拟设备
1 Router OS 2.9.27 三台
2 w inxpX P一台
虚拟机网络连接
Router OS- 1 Ether1桥接物理主机IP 192.168.0.164/24
Router OS – 1 Ether2分配给VMnet2 IP 1.0.0.1/24
Router OS – 2 Ether1桥接物理主机 IP 192.168.0.165/24
Router OS – 2 Ether2分配给VMnet3 IP 11.0.0.1/24
Router OS – 3 Ether 1分配给VMnet4 IP 172.16.0.254/24
Router OS – 3 Ether2分配给VMnet2 IP PPPOE自动获取
Router OS – 3 Ether3分配给VMnet3 IP 11.0.0.50/24
WINXP 网卡1分配给VMnet4 ip pppoe 自动获取
实验前已配置好的环境
1 确认各个接口 已PING通后删除ROU TEROS-3接口配置未实现NTH负载均衡。
2 ROUTER OS – 1和ROUTER OS- 3的PPPOE拨号服务器已配置好
3 ROUTER OS – 1和ROUTER OS – 2的NAT 已经配置完可以让WIN XP通过ROUTER OS-3 Ether3 的固定IP访问外部真实局域网。
配置过程以下操作均在ROUTER OS – 3进行
1 配置pppo e-c lient在Ether 2上给Ether 1和Ethe r3配置IP 以下所有注释不要更改为
其他的。
2 标记奇偶连接数据包(NTH)。因为是双线所以标记两条。再加一条
3 配置NAT。 1是随便设~TO-ADDRES S用脚本自动修改2就不能乱设了~要设置固定接
口的IP添加3这条是单线时 用到
4 添加静态路由表。 //3是用于单线双线时自动停用。 1、 2做路由分发这个不用选标记的路由包MARK空
5 添加bala nce脚本 PPPOE拨号掉线IP、 网关、NAT自动修改。
:local assign-address
:local new-address
:loc al status
:loc al adckip
:local new-gateway
:local x
:set x 1
#如果從1加1到等于变量x时则做,同时将X赋值给i
:for i from=1 to=$x do={
#查找接口名称=pppoe-out加i的接口是否激活,比如i循环到1那么就是p ppoe-out1.将结果赋给
:set status [/interfac e get [/interfac e find name=("pppoe-out" . $i)] running]
#如果stat us激活=真,则做
:if($s tatus=true)do={
#设置new-addres s,从IP地址列表里查找dy namic等于yes的接口,并取得该接口 的IP地址
:set new-address [/ip address get [/ip address find dynami c=yes interface=("pppoe-out" . $i)]addres s]
#将取得的IP地址,取总字符长度再减3
:set new-address [:pick$new-address 0([:len$new-address] -3)]
# //查找非动态接口地址,将它赋值给a ssign-addres s
:set assign-address [/ip address get [/ip address find dynami c=no interface=("pppoe-out" . $i)]addres s]
:set assign-address [:pick$assign-address 0([:len$assign-address] -3)]
#取拨号的动态网关可以将ppp oe-out1改为(“pppoe-out”.$i)
:set new-gateway [/ip addres s get [/ip addres s find dynami c=yes interf ace=pppoe-out1]netw ork]
#取netwa tch状态检查PPPOE拨号的hos t参数
:set adckip[/tool netwatch get [/tool netwatch find comment=$i]host]
#//如果pppo e-out加$i的$assign-addres s静态地址不等于$new-addres s,则做,将地址\子网\广播地址都设置为$new-addres s取得的地址.
:if ($assign-address != $new-address) do={ /ip addres s set [/ip addres s find commen t=$i]address=$new-address network=$new-address broadcast=$new-addres s
/ip route set[/ip route find comment=$i]gateway=$new-address
/ip fir nat set[/ip fir nat find comment=$i] to-addresses=$new-address
}
#如果新的网关不等于$adckip则将PPPO E拨号链路状态检查IP设为新的
host=$new-gateway]
}
}
}
6 添加光纤当线脚本fdow n 自动停用NT H负载所需的参数
:local new-gateway
:set new-gateway[/ip address get [/ip address find dynamic=yes interface=pppoe-out1]network]#固定IP的链路当掉后将网关默认路由的下一跳的网关设为PPPO E获取的网关
/ip route set [/ip route find c omment=3]gateway=$new-gateway
/ip route enable [/ip route find comment=3]
/ip route dis [/ip route find c omment=1]
/ip route dis [/ip route find c omment=2]
/ip firewall nat enable [/ip firewall nat find comment=3]
/ip firewall nat dis [/ip firewall nat find comment=1]
/ip firewall nat dis [/ip firewall nat find comment=2]
7 添加ADSL当线脚本ad sldownADSL掉线后将默认路由下一跳网关设为固定IP的网关
/ip route set [/ip route find c omment=3]gateway=11.0.0.1
/ip route enable [/ip route find comment=3]
/ip route dis [/ip route find c omment=1]
/ip route dis [/ip route find c omment=2]
/ip firewall nat enable [/ip firewall nat find comment=3]
/ip firewall nat dis [/ip firewall nat find comment=1]
/ip firewall nat dis[/ip firewall nat find comment=2]
8. .添加双线判断正常脚本li nkup。即两条线路UP的时候开启NTH负载均衡。
:global a
:global b
#取当前两条链路状态
:set a[/tool netwatch get [/tool netwatch find comment=1] status]
:set b[/tool netwatch get [/tool netwatch find host=11.0.0.1] status]
#如果两条线路都为UP则启用NTH负载均衡设置。
:if(($a="up")&&($b="up"))do={
/ip route dis [/ip route find c omment=3]
/ip route ena[/ip route find c omment=1]
/ip route ena[/ip route find c omment=2]
/ip firewall nat dis [/ip firewall nat find comment=3]
/ip firewall nat ena [/ip firewall nat find comment=1]
/ip firewall nat ena [/ip firewall nat find comment=2]}
9.为balan ce脚本设置定时运行
10.设置定时检查两条线路的状态UP或dow n则触发事件运行脚本。 //
加注释1一定要加不然不会自动更改host,因为这条是A DSL的线路。
好设置完毕还要运行下脚本初始化先fdown,再linku p,OK了现在测试nt h负载均衡 一个失误~哈哈没改成1
郁闷可能是论坛没开所以打不开网页
得了~看流量刚刚的配置生效需要一点时间
测试下载文件我这个XP的拨号是限制最大4M下载流量的等我开HTTP服务器先~看到了把 ether2是AD S L ether 3是固定IP因为XP的拨号帐号是最大下载4M所以两条线下载的不会超4M
好了现在测试其中掉线切换为单线先停掉1.0.0.1的路由器 当掉后自动停用了路由表。只起用3
打开论坛试试ping真实局域网的IP 192.168.0.158OK
再开启1.0.0.1
等下UP了之后就会启用负载均衡稍等~看
关掉固定IP的路由器11 .0.0.1稍等
启用单线了~再开启11.0.0.1测试负载均衡稍等UP了
LOCVPS发来了针对XEN架构VPS的促销方案,其中美国洛杉矶机房7折,其余日本/新加坡/中国香港等机房全部8折,优惠后日本/新加坡机房XEN VPS月付仅29.6元起。这是成立较久的一家国人VPS服务商,目前提供美国洛杉矶(MC/C3)、和中国香港(邦联、沙田电信、大埔)、日本(东京、大阪)、新加坡、德国和荷兰等机房VPS主机,基于XEN或者KVM虚拟架构,均选择国内访问线路不错的机房,适合建...
sharktech怎么样?sharktech (鲨鱼机房)是一家成立于 2003 年的知名美国老牌主机商,又称鲨鱼机房或者SK 机房,一直主打高防系列产品,提供独立服务器租用业务和 VPS 主机,自营机房在美国洛杉矶、丹佛、芝加哥和荷兰阿姆斯特丹,所有产品均提供 DDoS 防护。不知道大家是否注意到sharktech的所有服务器的带宽价格全部跳楼跳水,降幅简直不忍直视了,还没有见过这么便宜的独立服...
RAKsmart商家一直以来在独立服务器、站群服务器和G口和10G口大端口流量服务器上下功夫比较大,但是在VPS主机业务上仅仅是顺带,尤其是我们看到大部分主流商家都做云服务器,而RAKsmart商家终于开始做云服务器,这次试探性的新增美国硅谷机房一个方案。月付7.59美元起,支持自定义配置,KVM虚拟化,美国硅谷机房,VPC网络/经典网络,大陆优化/精品网线路,支持Linux或者Windows操作...