File "lb.sh"

Full path: /www/wwwroot/fabriciovc.eti.br/downloads/scripts/lb.sh
File size: 1.05 KiB (1073 bytes)
MIME-type: text/x-shellscript
Charset: 8 bit

Download   Open   Back

#!/bin/bash

## Limpar regras
ip route flush table L1
ip route flush table L2

#Limpar iptables
iptables -t nat -F
iptables -t mangle -F

#NAT
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

#Criar marcas nos pacotes	
iptables -t mangle -A PREROUTING -m tcp -p tcp -s 10.1.7.0/24 -d 0/0 --dport 80 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -m tcp -p tcp -s 10.1.7.0/24 -d 0/0 --dport 25 -j MARK --set-mark 2
#iptables -t mangle -A OUTPUT -j MARK --set-mark 3

#Links
ip route add 200.1.1.0/30 dev eth1 src 200.1.1.2 table L1
ip route add default via 200.1.1.1 table L1

ip route add 200.2.2.0/30 dev eth2 src 200.2.2.2 table L2
ip route add default via 200.2.2.1 table L2

ip rule add from 200.1.1.2 table L1
ip rule add from 200.2.2.2 table L2

#Marcação de pacote
ip rule add fwmark 1 table L1 
ip rule add fwmark 2 table L2 

#Balanceamento
ip route del default
ip route add default scope global nexthop via 200.1.1.1 dev eth1 weight 1 nexthop via 200.2.2.1 dev eth2 weight 1

ip route flush cache

PHP File Manager