|
This page is currently under construction. You can edit the article to help completing it. |
|
This page is currently under construction. You can edit the article to help completing it. |
Конфигурационный файл /etc/config/multiwan является частью пакета multiwan. Этот пакет представляет собой скрипт, который позволяет сделать конфигурацию с несколькими провайдерами простой и легко управляемой. Пакет multiwan содержит легко настраиваемый набор правил распределения нагрузки и отказоустойчивости.
В LuCI выполните шаги:
В результате будет установлен пакет multiwan и пакет управления им через LuCI luci-app-multiwan. После установки при очередном обновлении веб-страницы, Вы сможете настраивать пакет multiwan на странице Network → Multi-WAN
Выполните команды:
opkg update opkg install multiwan /etc/init.d/multiwan enable /etc/init.d/multiwan start /etc/init.d/multiwan single
В файле /etc/config/multiwan (по умолчанию маршрутизировать трафик через оба интерфейса WAN)
config 'multiwan' 'config'
option 'default_route' 'balancer'
| Имя параметра | Значение по умолчанию | Варианты значения | Описание |
|---|---|---|---|
default_route |
balancer | balancer/fastbalancer/<interface> | Выберите, как (куда) маршрутизировать трафик по умолчанию (то есть трафик, не регулируемый отдельными правилами) |
health_monitor |
parallel | parallel/serial | Мониторинг линков: параллельный или последовательный. Влияет на использование памяти. |
debug |
0 | 0/1 | Выводить отладочные сообщения в лог |
lan_if |
lan | <firewall lan zone> | Интерфейс LAN |
В командной строке (выставляем последовательный мониторинг живости линка):
uci set multiwan.config.health_monitor=serial uci commit multiwan /etc/init.d/multiwan restart
* Распределение нагрузки посредством netfilter называется Fast Balancer (лучшее распределение)
* Распределение нагрузки посредством iproute2 называется Load Balancer (лучшая совместимость)
* Правило wanrule для Fast Balancer - "fastbalancer"
* Правило wanrule для Load Balancer - "balancer"
Казалось бы, что fastbalancer должен давать лучший результат, но в действительности Вам нужно попробовать оба варианта, чтобы понять, какой из них лучше всего подходит для вашей ситуации.
config 'interface' 'wan'
option 'weight' '10'
option 'health_interval' '10'
option 'icmp_hosts' 'dns'
option 'timeout' '3'
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
option 'failover_to' 'wan2'
option 'dns' 'auto'
config 'interface' 'wan2'
option 'weight' '10'
option 'health_interval' '10'
option 'icmp_hosts' 'dns'
option 'timeout' '3'
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
option 'failover_to' 'wan'
option 'dns' 'auto'
| Имя параметра | Значение по умолчанию | Варианты значения | Описание |
|---|---|---|---|
weight |
10 | disable/1-10 | Load Balancer Distribution |
health_interval |
10 | disable/5/10/20/30/60/120 | Health Monitor Interval in seconds |
icmp_hosts |
? | disable/dns/gateway/<host> | Health Monitor ICMP Host(s) |
timeout |
? | disable/1-5/10 | Health Monitor ICMP Timeout |
health_fail_retries |
? | 1/3/5/10/15/20 | Attempts Before WAN Failover |
health_recovery_retries |
? | 1/3/5/10/15/20 | Attempts Before WAN Recovery |
failover_to |
? | disable/balancer/fastbalancer/<interface> | Failover Traffic Destination |
dns |
auto | auto/<dns> | DNS Server(s) |
uci delete multiwan.wan2 uci set multiwan.wwan=interface uci set multiwan.wwan.weight=3 uci set multiwan.wwan.health_interval=disable uci set multiwan.wwan.icmp_hosts=disable uci set multiwan.wwan.timeout=3 uci set multiwan.wwan.health_fail_retries=3 uci set multiwan.wwan.health_recovery_retries=5 uci set multiwan.wwan.failover_to=fastbalancer uci set multiwan.wwan.dns=auto uci commit multiwan /etc/init.d/multiwan restart
Для соединений 3G полезно указать серверы DNS вручную для каждого интерфейся WAN (в конфигурации multiwan).
При использовании двух или нескольких модемов 3G вам нужно добавить для каждого интерфейса WAN следующие правила в /etc/config/network:
option 'peerdns' '0' option 'defaultroute' '0'
Если несколько правил перекрываются, действует правило, расположенное последним в файле конфигурации. (
not clear enough.)
config 'mwanfw' option 'src' '192.168.1.0/24' option 'proto' 'udp' option 'port_type' 'source-ports' option 'ports' '5060,16384:16482' option 'wanrule' 'wan'
| Имя параметра | Значение по умолчанию | Варианты значения | Описание |
|---|---|---|---|
| src | all | all/<IP>/<hostname> | Адрес источника: all (любой), адрес IP либо имя хоста |
| dst | all | all/<IP>/<hostname> | Адрес получателя: all (любой), адрес IP либо имя хоста |
| port_type | dports | dports/source-ports | Тип порта: порт источника или порт получателя |
| ports | all | all/<port,port:range> | Номера портов: все, один либо диапазон |
| proto | all | all/tcp/udp/icmp/<custom> | Протокол: все, мнемоническое имя из /etc/protocols либо номер |
| wanrule | balancer/fastbalancer/<interface> | Правило распределения WAN: балансировка iproute2 или iptables, либо имя интерфейса | |
| failover_to | balancer/fastbalancer/<interface> | Резервный линк при отказе этого линка |
failover_to реализован патчем multiwan_per_mwanfw_failover.patch.txt
uci add multiwan mwanfw uci set multiwan.@mwanfw[-1].src=192.168.2.0/24 uci set multiwan.@mwanfw[-1].dst=www.whatismyip.com uci set multiwan.@mwanfw[-1].wanrule=fastbalancer uci commit multiwan /etc/init.d/multiwan restart
andyballon made quick installation guide and post it in https://forum.openwrt.org/viewtopic.php?id=23904&p=3 post #75
http://wiki.openwrt.org/doc/howto/tftp note: don't forget to login via telnet and change root passwd for ssh to work
I do this via /etc/config/newtork.
note: I removed port "0" from eth0_0 and gave it to eth0_2.
You can configure wan and wan2 proto as dhcp to strt and then use the web interface to configure the pppoe or static ip later. Use the same DNS servers I'm using if you're having DNS problems. Some ISPs only allow DNS connections from their IP blocks.
root@culiat-wg:~# cat /etc/config/network
config 'switch' 'eth0'
option 'enable' '1'
config 'switch_vlan' 'eth0_0'
option 'device' 'eth0'
option 'vlan' '0'
option 'ports' '1 2 3 5'
config 'switch_vlan' 'eth0_1'
option 'device' 'eth0'
option 'vlan' '1'
option 'ports' '4 5'
config 'switch_vlan' 'eth0_2'
option 'device' 'eth0'
option 'vlan' '2'
option 'ports' '0 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' 'eth0.0'
option 'proto' 'static'
option 'stp' '1'
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'
config 'interface' 'wan'
option 'ifname' 'eth0.1'
option 'proto' 'dhcp'
option 'dns' '216.146.35.113 216.146.36.113 8.8.8.8 8.8.4.4'
option 'defaultroute' '0'
option 'peerdns' '0'
config 'interface' 'wan2'
option 'ifname' 'eth0.2'
option 'dns' '216.146.35.113 216.146.36.113 8.8.8.8 8.8.4.4'
option 'proto' 'dhcp'
option 'defaultroute' '0'
option 'peerdns' '0'
ip, iptables, iptables-utils, iptables-mod-conntrack, iptables-mod-conntrack-extra, iptables-mod-ipopt and kmod-ipt-ipopt this is how I do it:
"opkg install http://downloads.openwrt.org/backfire/10.03/brcm47xx/packages/ip_2.6.29-1-2_brcm47xx.ipk" note: if you're new to all of this it's better to install all the applications first including multiwan before configuring vlans so your internet connection does not go kookie on you. If you did because you're folowing this guide, then just shutdown a interface like so: "ifconfig eth0.2 down"
Reboot to refresh the web ui. I always need to do this otherwise the link does not show up in networking.
Wans: Network > Interfaces > Wan/WAN2 note: when asked which firewall zone to add wan2 choose wan so it has the same firewall rules for wan connections. Otherwise you'll have to manually recreate the fw rules for wan2.
Multiwan: Network > Multiwan checkout the bottom page to see samples of the settings. here's how i got mine setup:
note: You'll get per connection distribution not per packet so don't expect one download to come from both gateways. Lots of talk on this in the internet. Failover = LoadBalancer for both links
note: checkout the examples Source, Destination, protocol, Ports, WAN Uplink all, all,all,all, Load Balancer all, all, UDP, all, wan ←- this is so all vpn and voip connection goes through 1 gateway only that's it!
root@culiat-wg:~# ip route show table 123
192.168.2.0/24 dev eth0.2 proto kernel scope link src 192.168.2.214
192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.1
114.108.201.0/24 dev eth0.1 proto kernel scope link src 114.108.201.49
default proto static
nexthop via 114.108.201.1 dev eth0.1 weight 1
nexthop via 192.168.2.1 dev eth0.2 weight 1
There's a problem if
Fix:
If you have two or more connections to the same ISP you should try:
ru/doc/uci/multiwan.txt · Last modified: 2012/11/25 12:58 by grumbler_eburg