浅析mwan3的配置文件中文说明

浅析mwan3的配置文件中文说明

/etc/config/mwan3 和 /etc/config/network

# This is a mwan3 example config. For mwan3 to work you will need at least这是mwan3的设置示例。至少需要以下几项才能运行mwan3

#
# - 2 interfaces( 2个接口
# - 2 members( 2个成员
# - 1 policy( 1个策略
# - 1 rule( 1条规则
#
# First define all your wan interfaces. Interface name must match with the
# name used in your network configuration:
首先要设置所有的wan口,wan口的名字必须跟network配置文件中的wan口名字一致
config 'interface' 'wan1'
        option 'enabled' '1'
        list 'track_ip' '8.8.4.4'( 这些IP都是测试IP,验证是否能ping的通。这里有4个,前两个都是google提供的免费DNS服务器,国内访问应该比较慢。
        list 'track_ip' '8.8.8.8'
        list 'track_ip' '208.67.222.222'
        list 'track_ip' '208.67.220.220'
        option 'reliability' '2'( 可靠性,测试以上IP的可靠性,必须是有响应的链接的个数。简单说就是要求上面的ip几个能ping通
        option 'count' '1'( ping几次
        option 'timeout' '2'( ping后如果超时,超时几秒
        option 'interval' '5'( 多次ping之间的间隔时间
        option 'down' '3'( 出现几个ping不通时就认定该wan口掉线了
        option 'up' '8'( 出现几个ping能成功时就认定已经掉线的wan口又上线了

config 'interface' 'wan2'
        option 'enabled' '1'
        list 'track_ip' '8.8.8.8'
        list 'track_ip' '208.67.220.220'
        option 'reliability' '1'
        option 'count' '1'
        option 'timeout' '2'
        option 'interval' '5'
        option 'down' '3'
        option 'up' '8'

# Next define a member and configure metric and weight values for this member.( 接着设置一个成员的权重和跃点值
# Each interface can have multiple member definitions. Give each member a correct( 每一个接口可以含有多重成员定义。每一个成员名称必须有正确的名称
# name (A-Z, a-z, 0-9, "_" and no spaces).

config 'member' 'wan1_m1_w3'
        option 'interface' 'wan1'
        option 'metric' '1'( 1-1000的范围
        option 'weight' '3'( 1-1000的范围

config 'member' 'wan1_m2_w3'
        option 'interface' 'wan1'
        option 'metric' '2'
        option 'weight' '3'

config 'member' 'wan2_m1_w2'
        option 'interface' 'wan2'
        option 'metric' '1'
        option 'weight' '2'

config 'member' 'wan2_m2_w2'
        option 'interface' 'wan2'
        option 'metric' '2'
        option 'weight' '2'

# After that create a routing policy. A routing policy consist of one or more( 然后创建一条路由策略。包括一个或者几个成员。每个策略必须有正确的名称。可以创建多重策略,以至于可以使不同的通信走不同的主/次wan口
# members. Give each policy a correct name (A-Z, a-z, 0-9, "_" and no spaces). You 
# can create multiple policies, so that it is possible for different traffic to
# have different primary and/or backup interfaces.

config 'policy' 'wan1_only'( 只走wan1
        list 'use_member' 'wan1_m1_w3'

config 'policy' 'wan2_only'( 只走wan2
        list 'use_member' 'wan2_m1_w2'

config 'policy' 'wan1_wan2_loadbalanced'( wan1、wan2负载平衡
        list 'use_member' 'wan1_m1_w3'
        list 'use_member' 'wan2_m1_w2'

config 'policy' 'wan1_pri_wan2_sec'( wan1主,wan2次
        list 'use_member' 'wan1_m1_w3'
        list 'use_member' 'wan2_m2_w2'

config 'policy' 'wan2_pri_wan1_sec'( wan2主,wan1次
        list 'use_member' 'wan1_m2_w3'
        list 'use_member' 'wan2_m1_w2'

# And to finish the config define your traffic rules. Rules are matched in top to( 最后来设置通信规则。他是从你设置的规则由上到下依次匹配,如果你定义的一条规则匹配上了,后面的规则都将忽略。如果平衡选项已经设置,mwan3将使每一个新的包走同一个目标主机地址来到达负载平衡,如果没有设置,那么mwan3会根据目标地址自动负载平衡
# bottom order. If you define a rule and it matches, all following rules are ignored.
#
# If the option equalize is set, mwan3 will load-balance each new session to the same
# host. If not set, it will load-balance based on destination.

config 'rule'
        option 'src_ip' '192.168.21.0/24'( 源IP,支持网段的表示方法
        option 'proto' 'tcp'( 指定协议
        option 'dest_port' '563'( 目标端口
        option 'use_policy' 'wan2_only'( 指定走上面设定的哪个策略

config 'rule'
        option 'src_ip' '192.168.21.0/24'
        option 'proto' 'tcp'
        option 'dest_port' '995'
        option 'use_policy' 'wan1_only'

config 'rule'
        option 'dest_ip' '88.154.0.0/16'( 目标IP
        option 'proto' 'tcp'
        option 'dest_port' '1024:65535'( 1024-65535的所有端口
        option 'equalize' '1'( 1为选中。如果选中,mwan3将使每一个新的包走同一个目标主机地址来到达负载平衡。如果没有,那么mwan3会根据目标地址自动负载平衡

        option 'use_policy' 'wan1_wan2_loadbalanced'

config 'rule'
        option 'dest_ip' '77.11.41.0/24'
        option 'proto' 'tcp'
        option 'dest_port' '1024:65535'
        option 'use_policy' 'wan1_pri_wan2_sec'

config 'rule'
        option 'dest_ip' '112.136.0.0/16'
        option 'proto' 'udp'
        option 'dest_port' '5352'
        option 'use_policy' 'wan2_pri_wan1_sec'

config 'rule'
        option 'dest_ip' '0.0.0.0/0'

        option 'use_policy' 'wan1_wan2_loadbalanced'


也可以参考:点击打开链接http://www.right.com.cn/forum/thread-124449-1-1.html

修改 /etc/config/firewall,增加规则,大部分是套用默认openwrt设置,把wan2接口加入防火墙wan区
config defaults
    option syn_flood    1
    option input        DROP
    option output        ACCEPT
    option forward        REJECT

config zone
    option name        lan
    option network        'lan'
    option input        ACCEPT
    option output        ACCEPT
    option forward        REJECT

config zone
    option name        wan
    option network        'wan wan2'
    option input        REJECT
    option output        ACCEPT
    option forward        REJECT
    option masq        1
    option mtu_fix        1

config forwarding
    option src        lan
    option dest        wan


  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值