先更新官方源 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。