You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.2 KiB
87 lines
2.2 KiB
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
DESC="Nouvelle configuration IPv6 du réseau + tests"
|
|
|
|
SYSTEMS="bigboss societe web"
|
|
|
|
# Fonction utilitaire : Récupère l'adresse IPv6 autoconfigurée
|
|
# $1 : host
|
|
# $2 : interface
|
|
# Exemple : getIPv6 bigboss eth0
|
|
|
|
getIPv6() {
|
|
echo $(vdn-ssh root@$1 'ip -6 addr show dev '$2' | grep inet6 | tr -s " " | cut -d " " -f 3 | cut -d "/" -f 1') | sed -re 's/[^[:print:]]//g'
|
|
}
|
|
|
|
testIPv6() {
|
|
echo
|
|
echo "test link between web and bigboss (Unique local address)"
|
|
echo
|
|
|
|
# réinitialise les interfaces
|
|
|
|
vdn-ssh root@bigboss "ifconfig eth0 down ; ifconfig eth0 up"
|
|
vdn-ssh root@web "ifconfig eth0 down ; ifconfig eth0 up"
|
|
vdn-ssh root@societe "
|
|
ifconfig eth0 down ; ifconfig eth0 up
|
|
ifconfig eth1 down ; ifconfig eth1 up
|
|
ifconfig eth2 down ; ifconfig eth2 up
|
|
|
|
echo 1 >/proc/sys/net/ipv6/conf/all/forwarding
|
|
"
|
|
|
|
# Ajoute les adresses IPv6 "locales uniques" en utilisant le suffixe
|
|
# de l'adresse "lien local"
|
|
#
|
|
# * la DMZ (web) aura le préfixe fc01
|
|
# * le réseau interne (bigboss) aura le préfixe fc00
|
|
#
|
|
# La fonction routage IPv6 est activé sur société
|
|
# et les route par défaut sont fixées sur web et bigboss
|
|
#
|
|
# un ping6 de bigboss vers web valide la config.
|
|
|
|
ipSocieteWeb=$(getIPv6 societe eth1)
|
|
ipSocieteWeb=$(echo $ipSocieteWeb | sed -re 's/fe80:/fc01:/')
|
|
vdn-ssh root@societe "ip -6 addr add $ipSocieteWeb/64 dev eth1"
|
|
|
|
ipSocieteBigboss=$(getIPv6 societe eth2)
|
|
ipSocieteBigboss=$(echo $ipSocieteBigboss | sed -re 's/fe80:/fc00:/')
|
|
vdn-ssh root@societe "ip -6 addr add $ipSocieteBigboss/64 dev eth2"
|
|
|
|
ipWeb=$(getIPv6 web eth0)
|
|
ipWeb=$(echo $ipWeb | sed -re 's/fe80:/fc01:/')
|
|
vdn-ssh root@web "ip -6 addr add $ipWeb/64 dev eth0"
|
|
|
|
ipBigboss=$(getIPv6 bigboss eth0)
|
|
ipBigboss=$(echo $ipBigboss | sed -re 's/fe80:/fc00:/')
|
|
vdn-ssh root@bigboss "ip -6 addr add $ipBigboss/64 dev eth0"
|
|
|
|
vdn-ssh root@web "
|
|
ip -6 route del ::/0 &> /dev/null
|
|
ip -6 route add ::/0 via $ipSocieteWeb"
|
|
vdn-ssh root@bigboss "
|
|
ip -6 route del ::/0 &> /dev/null
|
|
ip -6 route add ::/0 via $ipSocieteBigboss"
|
|
|
|
vdn-ssh root@bigboss "ping6 -c 3 -I eth0 $ipWeb"
|
|
}
|
|
|
|
|
|
run() {
|
|
setErrorHandler
|
|
echoStart
|
|
|
|
requireSshGuests $SYSTEMS
|
|
waitSsh $SYSTEMS
|
|
|
|
testIPv6
|
|
|
|
unsetErrorHandler
|
|
echoDone
|
|
}
|
|
|
|
|