openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络

openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络  


opkg install ftp://ftp.netlab7.com/multiwan_1.0.18.ipk ftp://ftp.netlab7.com/luci-app-multiwan_1.0.16.ipk

装完重启就会出现Network->Multi-WAN这个菜单

Load Balancer Distribution:负载比例分配,比重越大走的流量越多。
Health Monitor Frequency:健康检测频率,单位秒。就是每隔多少秒检测该WAN是否在线咯。
Health Monitor ICMP Host(s):用来健康检测PING的对象。我这里写的是baidu和163的IP。
Health Monitor ICMP Timeout:很好理解了,健康检测PING超时时间。
Attempts Before WAN Failover:该WAN发生故障了,不在线了?重复检测的次数,以确定真的掉线。
Attempts Before WAN Recovery:恢复该WAN流量前,检测该WAN是否真的在线的次数。晕,有点别扭,自己理解吧。
Failover Traffic Destination:该WAN发生故障后,转移到哪个网口。

openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络

安装所需的软件 macvlan、luci-app-multiwan

opkg update

opkg install ip

opkg install komd-macvlan

opkg install ftp://ftp.netlab7.com/multiwan_1.0.18.ipk ftp://ftp.netlab7.com/luci-app-multiwan_1.0.16.ipk

编辑/etc/rc.local 增加虚拟网卡、MAC地址
root@OpenWrt:~# vi /etc/rc.local 


增加
ip link add link eth1.1 eth2 type macvlan    增加wan2 虚拟网卡   eth1.1 对应前面记下的
ifconfig eth2 hw ether 00:11:22:33:44:5E
ifconfig eth2 up

ip link add link eth1.1 eth3 type macvlan    增加wan3虚拟网卡 eth1.1 对应前面记下的
ifconfig eth3 hw ether 00:11:22:33:44:6E
ifconfig eth3 up

如果需要更多 自行添加   少的话可以少加点,把MAC改成所需的地址

修改后保存 退出 
按esc 退出 。shift+:看见左下角显示 :输入wq 保存退出

///修改配置文件
vi /etc/config/multiwan

config 'multiwan' 'config'
option 'default_route' 'balancer'

config 'interface' 'wan'
option 'health_interval' '10'
option 'icmp_hosts' 'dns'
option 'timeout' '3'
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
option 'dns' 'auto'
option 'failover_to' 'balancer'
option 'weight' '5'

config 'interface' 'wan1'
option 'health_interval' '10'
option 'icmp_hosts' 'dns'
option 'timeout' '3'
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
option 'failover_to' 'balancer'
option 'dns' 'auto'
option 'weight' '5'

config 'mwanfw'
option 'ports' '443'
option 'wanrule' 'wan'

config 'mwanfw'
option 'wanrule' 'fastbalancer'

  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客
  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客

///修改配置文件 我的是RG100A-AA 设置的Vlan
vi /etc/config/network


config 'switch' 'eth1'
option 'reset' '1'
option 'enable_vlan' '1'

config 'switch_vlan'
option 'device' 'eth1'
option 'vlan' '0'
option 'ports' '0 1 2 5*'

config 'switch_vlan'
option 'device' 'eth1'
option 'vlan' '1'
option 'ports' '3 5*'

config 'interface' 'loopback'
option 'ifname' 'lo'
option 'proto' 'static'
option 'ipaddr' '127.0.0.1'
option 'netmask' '255.0.0.0'

config 'interface' 'lan'
option 'type' 'bridge'
option 'ifname' 'eth1.0'
option 'proto' 'static'
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'
option 'nat' '1'

config 'interface' 'wan'
option 'ifname' 'eth1.1'
option 'proto' 'pppoe'
option 'username' '^^07345807342'
option 'peerdns' '1'
option 'defaultroute' '1'
option 'password' 'E79ED0AB9EA7B4'
option 'macaddr' '00:74:04:02:B5:E9'

config 'interface' 'wan1'
option 'proto' 'pppoe'
option 'peerdns' '1'
option 'defaultroute' '1'
option 'ifname' 'eth2'
option 'macaddr' '00:1B:FC:BA:E2:C4'
option 'username' '^^HYAD104072787@5200.com'
option 'password' 'EB96D1A895A1'

  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客
  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客
  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客

///防火墙设置
/etc/config/firewall

config 'defaults'
option 'syn_flood' '1'
option 'input' 'ACCEPT'
option 'output' 'ACCEPT'
option 'forward' 'ACCEPT'

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

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

config 'forwarding'
option 'src' 'lan'
option 'dest' 'wan'

config 'rule'
option 'src' 'wan'
option 'proto' 'udp'
option 'dest_port' '68'
option 'target' 'ACCEPT'

config 'rule'
option 'src' 'wan'
option 'proto' 'tcp'
option 'dest_port' '2601'
option 'target' 'ACCEPT'

config 'include'
option 'path' '/etc/firewall.user'

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

config 'forwarding'
option 'src' 'lan'
option 'dest' 'wan1'

config 'redirect'
option 'src' 'wan'
option '_name' 'webadmin'
option 'proto' 'tcpudp'
option 'src_dport' '81'
option 'dest_ip' '192.168.1.1'
option 'dest_port' '80'

config 'rule'
option 'target' 'ACCEPT'
option 'src' 'wan'
option 'proto' 'tcpudp'
option 'dest_port' '22'

  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客
  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客
  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客

3M双拔叠加后的效果图,最高能到630kb

  openwrt Multi-WAN+macvlan单WAN多帐户 多拔叠加网络 - 耗子 - 我的博客

设置自动换网关

/etc/ppp/ip-up.d/wan-up.sh

wan_ip=$(grep network.wan.ipaddr /tmp/state/network |cut -d"=" -f2 | cut -d" " -f1)
wan_gateway=$(grep network.wan.gateway /tmp/state/network |cut -d"=" -f2 | cut -d" " -f1)
wan_ifname=$(grep network.wan.ifname /tmp/state/network |cut -d"=" -f2 | cut -d" " -f1)


wan1_ip=$(grep network.wan1.ipaddr /tmp/state/network |cut -d"=" -f2 | cut -d" " -f1)
wan1_gateway=$(grep network.wan1.gateway /tmp/state/network |cut -d"=" -f2 | cut -d" " -f1)
wan1_ifname=$(grep network.wan1.ifname /tmp/state/network |cut -d"=" -f2 | cut -d" " -f1)
route add default gw $wan_ip
echo $wan_ip
echo $wan1_ip

if ($wan_gateway=$wan1_gateway); then
#if (wan_gateway=wan1_gateway); then
   echo ifdown wan1....
   ifdown wan1
   echo ifup wan1....
   ifup wan1
else
    /etc/init.d/multiwan restart
fi
echo OK.......

执行chmod +x /etc/ppp/ip-up.d/wan-up.sh


目前该组件还不太完美,有个小问题(不知道是不是因为有3G才这样的):
当PPPoE和3G都接入后,需要手动把Multi-WAN再启动一次,也就按下Multi-WAN设置页面的“Save & Apply”按钮,合并才会生效。
貌似不是很方面,但是有个解决办法,修改一个脚本/etc/hotplug.d/net/10-net:

case "$ACTION" in
add|register)
case "$PHYSDEVDRIVER" in
   natsemi) sleep 1;;
esac
addif
在上面语句后面添加:

sh /usr/bin/multiwan restart
当检测有网络接入时,自动重启Multi-WAN。
经过上面修改后,3G+PPPoE基本上完美了,无需考虑顺序问题了,3G和PPPoE随便插,不管谁先谁后,谁上谁下,随便插好了, 哈哈

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是帮助你搭建QEMU OpenWrt + Cortex-A7 + Visual Studio虚拟开发和debug环境的步骤: 1. 安装QEMU 首先,你需要安装QEMU模拟器。你可以从官网下载QEMU的最新版本:https://www.qemu.org/download/ 。 2. 下载OpenWrt 接下来,你需要下载OpenWrt的镜像文件。你可以从OpenWrt的官网下载:https://openwrt.org/downloads 。 3. 安装交叉编译工具链 你需要安装针对Cortex-A7处理器的交叉编译工具链。你可以从ARM的官网下载:https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads 。 安装完工具链后,将其添加到系统的PATH环境变量中。 4. 启动OpenWrt 使用QEMU启动OpenWrt。命令如下: ``` qemu-system-arm -M vexpress-a9 -m 256M -kernel openwrt-armvirt-32-zImage -append "root=/dev/vda rootfstype=ext4 rootwait console=ttyAMA0" -drive file=openwrt-armvirt-32-root.ext4,if=none,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=network0 -device virtio-net-device,netdev=network0 ``` 5. 连接到OpenWrt 使用SSH连接到OpenWrt。命令如下: ``` ssh -t root@localhost -p 2222 ``` 6. 安装Visual Studio 安装Windows版的Visual Studio。你可以从Microsoft的官网下载:https://visualstudio.microsoft.com/downloads/ 。 7. 配置Visual Studio 在Visual Studio中,选择“工具”>“选项”>“调试”>“远程调试”,然后添加一个新的远程调试器。 设置目标为OpenWrt的IP地址和端口号(默认为2222)。选择“使用SSH连接”选项,并输入用户名和密码。 8. 开始调试 现在你已经准备好在Visual Studio中进行调试了。首先,设置断点或者在代码中插入调试语句。然后,使用Visual Studio启动远程调试器,并连接到OpenWrt。 现在你可以在Visual Studio中进行调试了。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值