multiwan
This commit is contained in:
@@ -0,0 +1,269 @@
|
||||
# Настройка MultiWAN на MikroTik RouterOS v7
|
||||
|
||||
## Описание конфигурации
|
||||
|
||||
Данная инструкция описывает настройку MultiWAN с тремя провайдерами для обеспечения отказоустойчивости и распределения VPN соединений по разным внешним IP адресам.
|
||||
|
||||
### Провайдеры:
|
||||
1. **Ростелеком (RTK-Internet)** - ether8, PPPoE, внешний IP: 87.103.241.8
|
||||
2. **Электронный город** - ether1, DHCP, внешний IP: 178.49.24.65
|
||||
3. **МТС** - ether7, DHCP, внешний IP: 109.174.26.78
|
||||
|
||||
## Схема подключения
|
||||
|
||||
```
|
||||
[Ростелеком] ---- ether8 ---- [MikroTik Router]
|
||||
[Эл.Город] ---- ether1 ---- [MikroTik Router] ---- LAN
|
||||
[МТС] ---- ether7 ---- [MikroTik Router]
|
||||
```
|
||||
|
||||
## Базовые настройки
|
||||
|
||||
### 1. Настройка интерфейсов
|
||||
|
||||
```bash
|
||||
# Настройка интерфейсов
|
||||
/interface ethernet
|
||||
set [ find default-name=ether1 ] comment="Электронный город"
|
||||
set [ find default-name=ether7 ] comment="МТС"
|
||||
set [ find default-name=ether8 ] comment="Ростелеком"
|
||||
|
||||
# Создание списка WAN интерфейсов
|
||||
/interface list
|
||||
add name=WAN
|
||||
|
||||
# Добавление интерфейсов в WAN список
|
||||
/interface list member
|
||||
add interface=ether1 list=WAN
|
||||
add interface=ether7 list=WAN
|
||||
add interface=ether8 list=WAN
|
||||
|
||||
# Настройка локальной сети
|
||||
/interface bridge
|
||||
add name=br-lan
|
||||
/interface bridge port
|
||||
add bridge=br-lan interface=ether2
|
||||
add bridge=br-lan interface=ether3
|
||||
add bridge=br-lan interface=ether4
|
||||
add bridge=br-lan interface=ether5
|
||||
add bridge=br-lan interface=ether6
|
||||
```
|
||||
|
||||
### 2. Настройка IP адресов
|
||||
|
||||
```bash
|
||||
# IP адреса для провайдеров
|
||||
/ip address
|
||||
add address=192.168.88.254/24 interface=br-lan comment="LAN"
|
||||
|
||||
# PPPoE для Ростелеком
|
||||
/interface pppoe-client
|
||||
add name=pppoe-rtk interface=ether8 user=your_username password=your_password
|
||||
add address=87.103.241.8/32 interface=pppoe-rtk comment="Ростелеком"
|
||||
|
||||
# DHCP для Электронного города
|
||||
/ip dhcp-client
|
||||
add interface=ether1 name=dhcp-elcity
|
||||
add address=178.49.24.65/32 interface=ether1 comment="Электронный город"
|
||||
|
||||
# DHCP для МТС
|
||||
/ip dhcp-client
|
||||
add interface=ether7 name=dhcp-mts
|
||||
add address=109.174.26.78/32 interface=ether7 comment="МТС"
|
||||
```
|
||||
|
||||
### 3. Настройка NAT
|
||||
|
||||
```bash
|
||||
# Включение masquerading для всех WAN интерфейсов
|
||||
/ip firewall nat
|
||||
add action=masquerade chain=srcnat out-interface-list=WAN
|
||||
```
|
||||
|
||||
## Создание таблиц маршрутизации
|
||||
|
||||
### 1. Дополнительные routing tables
|
||||
|
||||
```bash
|
||||
# Создание таблиц маршрутизации для каждого провайдера
|
||||
/routing table
|
||||
add disabled=no fib name=rtab-rtk comment="Ростелеком"
|
||||
add disabled=no fib name=rtab-elcity comment="Электронный город"
|
||||
add disabled=no fib name=rtab-mts comment="МТС"
|
||||
```
|
||||
|
||||
### 2. Маршруты по умолчанию
|
||||
|
||||
```bash
|
||||
# Основные маршруты по умолчанию
|
||||
/ip route
|
||||
add distance=251 gateway=87.103.241.1 comment="Ростелеком основной"
|
||||
add distance=252 gateway=178.49.24.1 comment="Эл.Город основной"
|
||||
add distance=253 gateway=109.174.26.1 comment="МТС основной"
|
||||
|
||||
# Маршруты в отдельных таблицах
|
||||
/ip route
|
||||
add gateway=87.103.241.1 routing-table=rtab-rtk comment="Ростелеком таблица"
|
||||
add gateway=178.49.24.1 routing-table=rtab-elcity comment="Эл.Город таблица"
|
||||
add gateway=109.174.26.1 routing-table=rtab-mts comment="МТС таблица"
|
||||
```
|
||||
|
||||
## Настройка маркировки (Mangle)
|
||||
|
||||
### 1. Маркировка соединений по интерфейсам
|
||||
|
||||
```bash
|
||||
# Маркировка соединений по входящим интерфейсам
|
||||
/ip firewall mangle
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface=pppoe-rtk new-connection-mark=con-rtk passthrough=yes comment="Маркировка Ростелеком"
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface=ether1 new-connection-mark=con-elcity passthrough=yes comment="Маркировка Эл.Город"
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface=ether7 new-connection-mark=con-mts passthrough=yes comment="Маркировка МТС"
|
||||
```
|
||||
|
||||
### 2. Маркировка маршрутизации
|
||||
|
||||
```bash
|
||||
# Маркировка маршрутизации для исходящего трафика
|
||||
/ip firewall mangle
|
||||
add action=mark-routing chain=prerouting connection-mark=con-rtk in-interface-list=!WAN new-routing-mark=rtab-rtk passthrough=yes comment="Роутинг Ростелеком"
|
||||
add action=mark-routing chain=prerouting connection-mark=con-elcity in-interface-list=!WAN new-routing-mark=rtab-elcity passthrough=yes comment="Роутинг Эл.Город"
|
||||
add action=mark-routing chain=prerouting connection-mark=con-mts in-interface-list=!WAN new-routing-mark=rtab-mts passthrough=yes comment="Роутинг МТС"
|
||||
|
||||
# Маркировка для исходящих соединений
|
||||
/ip firewall mangle
|
||||
add action=mark-routing chain=output connection-mark=con-rtk new-routing-mark=rtab-rtk passthrough=yes comment="Output Ростелеком"
|
||||
add action=mark-routing chain=output connection-mark=con-elcity new-routing-mark=rtab-elcity passthrough=yes comment="Output Эл.Город"
|
||||
add action=mark-routing chain=output connection-mark=con-mts new-routing-mark=rtab-mts passthrough=yes comment="Output МТС"
|
||||
```
|
||||
|
||||
## Настройка отказоустойчивости
|
||||
|
||||
### 1. Рекурсивные маршруты для failover
|
||||
|
||||
```bash
|
||||
# Рекурсивные маршруты для автоматического переключения
|
||||
/ip route
|
||||
add distance=1 gateway=87.103.241.1 routing-table=rtab-elcity comment="Failover Ростелеком->Эл.Город"
|
||||
add distance=1 gateway=87.103.241.1 routing-table=rtab-mts comment="Failover Ростелеком->МТС"
|
||||
add distance=1 gateway=178.49.24.1 routing-table=rtab-rtk comment="Failover Эл.Город->Ростелеком"
|
||||
add distance=1 gateway=178.49.24.1 routing-table=rtab-mts comment="Failover Эл.Город->МТС"
|
||||
add distance=1 gateway=109.174.26.1 routing-table=rtab-rtk comment="Failover МТС->Ростелеком"
|
||||
add distance=1 gateway=109.174.26.1 routing-table=rtab-elcity comment="Failover МТС->Эл.Город"
|
||||
```
|
||||
|
||||
### 2. Настройка health check
|
||||
|
||||
```bash
|
||||
# Создание health check для провайдеров
|
||||
/tool ping
|
||||
add address=8.8.8.8 interval=10s name=ping-rtk
|
||||
add address=8.8.8.8 interval=10s name=ping-elcity
|
||||
add address=8.8.8.8 interval=10s name=ping-mts
|
||||
|
||||
# Настройка автоматического переключения при недоступности
|
||||
/ip route
|
||||
add distance=1 gateway=87.103.241.1 routing-table=rtab-rtk check-gateway=ping
|
||||
add distance=1 gateway=178.49.24.1 routing-table=rtab-elcity check-gateway=ping
|
||||
add distance=1 gateway=109.174.26.1 routing-table=rtab-mts check-gateway=ping
|
||||
```
|
||||
|
||||
## Настройка VPN соединений
|
||||
|
||||
### 1. Создание VPN интерфейсов для каждого провайдера
|
||||
|
||||
```bash
|
||||
# VPN интерфейсы для разных провайдеров
|
||||
/interface ovpn-client
|
||||
add name=ovpn-rtk connect-to=your_vpn_server_rtk user=your_vpn_user password=your_vpn_password
|
||||
add name=ovpn-elcity connect-to=your_vpn_server_elcity user=your_vpn_user password=your_vpn_password
|
||||
add name=ovpn-mts connect-to=your_vpn_server_mts user=your_vpn_user password=your_vpn_password
|
||||
```
|
||||
|
||||
### 2. Маркировка VPN трафика
|
||||
|
||||
```bash
|
||||
# Маркировка VPN соединений по провайдерам
|
||||
/ip firewall mangle
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface=ovpn-rtk new-connection-mark=con-rtk passthrough=yes comment="VPN Ростелеком"
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface=ovpn-elcity new-connection-mark=con-elcity passthrough=yes comment="VPN Эл.Город"
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface=ovpn-mts new-connection-mark=con-mts passthrough=yes comment="VPN МТС"
|
||||
```
|
||||
|
||||
## Настройка балансировки нагрузки
|
||||
|
||||
### 1. Политика балансировки
|
||||
|
||||
```bash
|
||||
# Настройка политики для распределения трафика
|
||||
/ip firewall mangle
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface-list=!WAN new-connection-mark=con-rtk passthrough=yes src-address=192.168.88.0/24 dst-address=0.0.0.0/0 comment="Балансировка Ростелеком"
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface-list=!WAN new-connection-mark=con-elcity passthrough=yes src-address=192.168.88.0/24 dst-address=0.0.0.0/0 comment="Балансировка Эл.Город"
|
||||
add action=mark-connection chain=prerouting connection-mark=no-mark in-interface-list=!WAN new-connection-mark=con-mts passthrough=yes src-address=192.168.88.0/24 dst-address=0.0.0.0/0 comment="Балансировка МТС"
|
||||
```
|
||||
|
||||
## Проверка конфигурации
|
||||
|
||||
### 1. Проверка таблиц маршрутизации
|
||||
|
||||
```bash
|
||||
# Просмотр таблиц маршрутизации
|
||||
/routing table print
|
||||
|
||||
# Просмотр маршрутов в каждой таблице
|
||||
/ip route print where routing-table=rtab-rtk
|
||||
/ip route print where routing-table=rtab-elcity
|
||||
/ip route print where routing-table=rtab-mts
|
||||
```
|
||||
|
||||
### 2. Проверка маркировки
|
||||
|
||||
```bash
|
||||
# Просмотр правил mangle
|
||||
/ip firewall mangle print
|
||||
|
||||
# Проверка connection marks
|
||||
/ip firewall connection print
|
||||
```
|
||||
|
||||
### 3. Тестирование подключения
|
||||
|
||||
```bash
|
||||
# Тест подключения через разные провайдеры
|
||||
/tool traceroute 8.8.8.8 routing-table=rtab-rtk
|
||||
/tool traceroute 8.8.8.8 routing-table=rtab-elcity
|
||||
/tool traceroute 8.8.8.8 routing-table=rtab-mts
|
||||
```
|
||||
|
||||
## Мониторинг и логирование
|
||||
|
||||
### 1. Настройка логирования
|
||||
|
||||
```bash
|
||||
# Логирование изменений маршрутизации
|
||||
/system logging
|
||||
add action=memory topics=route
|
||||
add action=memory topics=firewall
|
||||
```
|
||||
|
||||
### 2. Мониторинг интерфейсов
|
||||
|
||||
```bash
|
||||
# Мониторинг состояния интерфейсов
|
||||
/interface monitor-traffic interface=pppoe-rtk
|
||||
/interface monitor-traffic interface=ether1
|
||||
/interface monitor-traffic interface=ether7
|
||||
```
|
||||
|
||||
## Заключение
|
||||
|
||||
Данная конфигурация обеспечивает:
|
||||
- Отказоустойчивость при выходе из строя одного из провайдеров
|
||||
- Распределение VPN соединений по разным внешним IP адресам
|
||||
- Балансировку нагрузки между провайдерами
|
||||
- Автоматическое переключение при недоступности каналов
|
||||
|
||||
Для применения конфигурации выполните команды последовательно, начиная с базовых настроек интерфейсов и заканчивая настройкой VPN соединений.
|
||||
|
||||
## Источники
|
||||
|
||||
- [Multiwan and routing in MikroTik ROS v7](https://mikrotik-training.ru/files/MUoM/2021/kuznetsov.pdf) - Владимир Кузнецов, Yandex
|
||||
Reference in New Issue
Block a user