先更新官方源 web
安装所需的软件 macvlan、luci-app-multiwan 网络
opkg update app
opkg install ip tcp
opkg install komd-macvlan spa
opkg install .net
编辑/etc/rc.local 增长虚拟网卡、MAC地址
root@OpenWrt :~# vi /etc/rc.local rest
增长
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 dns
若是须要更多 自行添加 少的话能够少加点,把MAC改为所需的地址
修改后保存 退出
按esc 退出 。shift+:看见左下角显示 :输入wq 保存退出 ip
///修改配置文件
vi /etc/config/multiwan ci
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'
///防火墙设置
/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'
设置自动换网关
/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
case "$ACTION" in
add|register)
case "$PHYSDEVDRIVER" in
natsemi) sleep 1;;
esac
addif
在上面语句后面添加:
sh /usr/bin/multiwan restart 当检测有网络接入时,自动重启Multi-WAN。