-
Notifications
You must be signed in to change notification settings - Fork 0
/
slave.sh
70 lines (58 loc) · 2.08 KB
/
slave.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
## SLAVE ##
# Variaveis Slave
SLAVELAN="192.168.100.20" #EM0
SLAVEFW="10.10.10.2" #EM1
SLAVEWAN="192.168.10.202" #EM2
# Variaveis Compartilhado
SHAREDLAN="192.168.100.100"
SHAREDLANBC="192.168.100.255"
SHAREDWAN="192.168.10.250"
SHAREDWANBC="192.168.10.255"
DEFAULTGW="192.168.10.1"
#Cria arquivos hostname
touch /etc/hostname.em0
touch /etc/hostname.em1
touch /etc/hostname.em2
touch /etc/hostname.pfsync0
touch /etc/hostname.carp1
touch /etc/hostname.carp2
touch /etc/sysctl.conf
#Cria arquivo para default gw
touch /etc/mygate
echo $DEFAULTGW > /etc/mygate
##Permite o redirecionamento de pacotes IP
sysctl -w net.inet.ip.forwarding=1
echo "net.inet.ip.forwarding=1" >> /etc/sysctl.conf
## Habilitar o protocolo CARP
sysctl -w net.inet.carp.allow=1
echo "net.inet.carp.allow=1" >> /etc/sysctl.conf
## Habilitar o preemption e o grupo de interface failover
echo "net.inet.carp.preempt=1" >> /etc/sysctl.conf
sysctl -w net.inet.carp.preempt=1
## Configuracao LAN MASTER
ifconfig em0 $SLAVELAN netmask 255.255.255.0
#Adiciona configuracoes no boot
echo "inet $SLAVELAN 255.255.255.0 NONE" > /etc/hostname.em0
## Configuracao WAN SLAVE
ifconfig em2 $SLAVEWAN net mask 255.255.255.0
echo "inet $SLAVEWAN 255.255.255.0 NONE" > /etc/hostname.em2
## Configuracao PFSYNC
ifconfig em1 $SLAVEFW netmask 255.255.255.0
echo "inet $SLAVEFW 255.255.255.0 NONE" > /etc/hostname.em1
ifconfig pfsync0 syncdev em1
ifconfig pfsync0 up
echo "up syncdev em1" > /etc/hostname.pfsync0
## Configuracao CARP LAN
ifconfig carp1 create
ifconfig carp1 vhid 1 carpdev em0 pass senhalan advskew 200 state backup $SHAREDLAN 255.255.255.0
echo "inet $SHAREDLAN 255.255.255.0 $SHAREDLANBC vhid 1 carpdev em0 pass senhalan advskew 200 state backup" > /etc/hostname.carp1
## Configuracao CARP WAN
ifconfig carp2 create
ifconfig carp2 vhid 2 carpdev em2 pass senhawan advskew 200 state backup $SHAREDWAN 255.255.255.0
echo "inet $SHAREDWAN 255.255.255.0 $SHAREDWANBC vhid 2 carpdev em2 pass senhawan advskew 200 state backup" > /etc/hostname.carp2
#Liga todas interfaces
ifconfig em0 up
ifconfig em1 up
ifconfig em2 up
sh /etc/netstart