Enviado em 04/01/2021 - 11:59h
OláEnviado em 04/01/2021 - 12:14h
https://lstein.github.io/Net-ISP-Balance/Enviado em 04/01/2021 - 16:30h
Enviado em 04/01/2021 - 18:07h
Enviado em 05/01/2021 - 08:31h
Enviado em 05/01/2021 - 09:12h
Enviado em 05/01/2021 - 12:08h
Você pode tentar dessa maneira. Estou pressupondo que nesse seu servidor, o iptables já esteja configurado e fazendo NAT de saída com os IPs dos seus ISPs (Vivo e Net).1 rt_isp1 # Vivo 2 rt_isp2 # Net
net.ipv4.fib_multipath_hash_policy=1 net.ipv4.conf.all.arp_filter=1 net.ipv4.conf.all.arp_ignore=1 net.ipv4.conf.all.arp_announce=2 net.ipv4.conf.default.arp_filter=1 net.ipv4.conf.default.arp_ignore=1 net.ipv4.conf.default.arp_announce=2 net.ipv4.conf.all.rp_filter=2 net.ipv4.conf.default.rp_filter=2
#!/bin/sh PATH='/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' export LC_ALL='POSIX' # Variaveis de controle. Altere conforme necessario TABLE_LINK1='rt_isp1' # Vivo TABLE_LINK2='rt_isp2' # Net GW_LINK1='xxx.xxx.xxx.xxx' # Gateway/Vivo GW_LINK2='yyy.yyy.yyy.yyy' # Gateway/Net IFACE_LINK1='ethX' # Interface/Vivo IFACE_LINK2='ethY' # Interface/Net start() { echo "Starting load-balancing: $(which ip)" # Populando as novas tabelas de roteamento ip route add 127.0.0.0/8 dev lo table "$TABLE_LINK1" ip route add 127.0.0.0/8 dev lo table "$TABLE_LINK2" ip route show table main | grep -v '^default' | while IFS= read -r i; do ip route add $i table "$TABLE_LINK1" ip route add $i table "$TABLE_LINK2" done # Definindo os gateways padroes para as novas tabelas de roteamento ip route add default via "$GW_LINK1" table "$TABLE_LINK1" proto static metric 1 quickack 1 ip route add default via "$GW_LINK2" table "$TABLE_LINK2" proto static metric 1 quickack 1 # Politicas de roteamento ip addr show dev "$IFACE_LINK1" | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | xargs -I {} ip rule add from {} table "$TABLE_LINK1" ip addr show dev "$IFACE_LINK1" | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | xargs -I {} ip rule add to {} table "$TABLE_LINK1" ip addr show dev "$IFACE_LINK2" | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | xargs -I {} ip rule add from {} table "$TABLE_LINK2" ip addr show dev "$IFACE_LINK2" | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | xargs -I {} ip rule add to {} table "$TABLE_LINK2" # Removendo os gateways padroes da tabela principal... ip route flush default # ... e adicionando politica de rotas com multiplos caminhos atraves de balanceamento de conexoes ip route add default proto static quickack 1 scope global nexthop via "$GW_LINK1" dev "$IFACE_LINK1" weight 1 nexthop via "$GW_LINK2" dev "$IFACE_LINK2" weight 1 # Limpando cache residual ip route flush cache return 0 } stop() { echo 'Stopping load-balancing' # Limpando as politicas de roteamento ip route flush default for i in "$TABLE_LINK1" "$TABLE_LINK2"; do ip route flush table $i ip rule flush table $i done # Restaurando gateways na tabela principal ip route add default via "$GW_LINK1" proto static metric 1 quickack 1 ip route add default via "$GW_LINK2" proto static metric 2 quickack 1 # Limpando cache residual ip route flush cache return 0 } case "$1" in 'start') start;; 'stop') stop;; 'restart') stop; sleep 1; start;; *) echo "Usage: $(basename $0) start|stop|restart" esac
chmod 755 /usr/local/sbin/load-balance.sh
/usr/local/sbin/load-balance.sh start
Enviado em 06/01/2021 - 17:55h
Interessante o script. Vou testar ele.Enviado em 11/01/2021 - 12:47h
Testei o script do smarcell aqui no trampo e funfou de boas.Enviado em 19/02/2021 - 09:46h
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Criando uma Infraestrutura para uma micro Empresa
Criar entrada (menuentry) ISO no Grub
Como gerar qualquer emoji ou símbolo unicode a partir do seu teclado
Instalando o Pi-Hole versão v5.18.4 depois do lançamento da versão v6.0
Instalar o VIM 9.1 no Debian 12
Como saber o range de um IP público?
Muitas dificuldades ao instalar distro Linux em Notebook Sony Vaio PCG-6131L (VPCEA24FM)
Problema no boot do Linux Mint Cinnamon 22 (4)
Atualização do Google Chrome do Ubuntu [RESOLVIDO] (2)
Instalei Windows 11 e não alterou o Grub do Debian (1)
Jogos baixados na Central de Aplicativos mas que não abrem (0)