Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scripts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
infra
scripts
Commits
8f5def26
Commit
8f5def26
authored
Nov 21, 2023
by
Joab Bremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update rc.rotas
parent
54d0e6d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
10 deletions
+33
-10
rc.rotas
rotas_failover/rc.rotas
+33
-10
No files found.
rotas_failover/rc.rotas
View file @
8f5def26
#!/usr/bin/bash
### Link 1
IF_LINK1
=
"eth2"
MASK_LINK1
=
"29"
IP_LINK1
=
"177.101.123.202"
GW_LINK1
=
"177.101.123.201"
NT_LINK1
=
"177.101.123.200"
declare
-g
IF_LINK1
=
"eth2"
declare
-g
MASK_LINK1
declare
-g
IP_LINK1
declare
-g
GW_LINK1
declare
-g
NT_LINK1
### Link 2
IF_LINK2
=
"eth3"
MASK_LINK2
=
"24"
IP_LINK2
=
"192.168.2.240"
GW_LINK2
=
"192.168.2.2"
NT_LINK2
=
"192.168.2.0"
declare
-g
IF_LINK2
=
"eth3"
declare
-g
MASK_LINK2
declare
-g
IP_LINK2
declare
-g
GW_LINK2
declare
-g
NT_LINK2
obter_informacoes_rede
(){
local
interface_param
=
$1
IP_CIDR
=
$(
nmcli
-g
IP4.ADDRESS dev show
$interface_param
)
IP_ADDRESS
=
$(
echo
$IP_CIDR
|
cut
-d
'/'
-f1
)
SUBNET_MASK
=
$(
echo
$IP_CIDR
|
cut
-d
'/'
-f2
)
GATEWAY
=
$(
nmcli
-g
IP4.GATEWAY dev show
$interface_param
)
NETWORK_ADDRESS
=
$(
ipcalc
-n
-b
-n
-s
-b
$IP_CIDR
|
grep
Network |
awk
'{print $2}'
)
echo
"
$IP_ADDRESS
$SUBNET_MASK
$GATEWAY
$NETWORK_ADDRESS
"
}
up_link1_default
(){
logger
"fail-over: Alterando para a rota padrão via
$GW_LINK1
"
...
...
@@ -46,6 +56,19 @@ check_link() {
main
(){
logger
"fail-over: Iniciando Servico"
resultado
=
$(
obter_informacoes_rede
$IF_LINK1
)
IP_LINK1
=
$(
echo
$resultado
|
cut
-d
' '
-f1
)
MASK_LINK1
=
$(
echo
$resultado
|
cut
-d
' '
-f2
)
GW_LINK1
=
$(
echo
$resultado
|
cut
-d
' '
-f3
)
NT_LINK1
=
$(
echo
$resultado
|
cut
-d
' '
-f4
)
resultado
=
$(
obter_informacoes_rede
$IF_LINK1
)
IP_LINK2
=
$(
echo
$resultado
|
cut
-d
' '
-f1
)
MASK_LINK2
=
$(
echo
$resultado
|
cut
-d
' '
-f2
)
GW_LINK2
=
$(
echo
$resultado
|
cut
-d
' '
-f3
)
NT_LINK2
=
$(
echo
$resultado
|
cut
-d
' '
-f4
)
#Definindo rotas link principal
ip route add
$NT_LINK1
/
$MASK_LINK1
dev
$IF_LINK1
ip route add
$NT_LINK1
/
$MASK_LINK1
dev
$IF_LINK1
table T1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment