Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
technique:archives:network-design-sim [2015/11/29 19:49] admin localhost |
technique:archives:network-design-sim [2015/11/29 21:12] (Version actuelle) admin [Scripts] |
||
---|---|---|---|
Ligne 9: | Ligne 9: | ||
* CHD fait ses annonces BGP à 1 pair [[http://www.fullsave.com/prestations/transit-bgp/|géré par FullSave]] | * CHD fait ses annonces BGP à 1 pair [[http://www.fullsave.com/prestations/transit-bgp/|géré par FullSave]] | ||
* CHD loue 2 liens fibre vers Saint-Gaudens | * CHD loue 2 liens fibre vers Saint-Gaudens | ||
- | * 1 routeur (RT) par arrivée fibre (Serge G. et ZAC Landes) | + | * 1 routeur (RT) par arrivée fibre (av F.Mitterand et ZAC Landes) |
* 1 grand LAN radio (ponts transparents) avec les 2 RT et tous les adhérents | * 1 grand LAN radio (ponts transparents) avec les 2 RT et tous les adhérents | ||
- | Schéma : {{:technique:archives:capture-simu-gns3.png?linkonly|:technique:archives:capture-simu-gns3.png}} | + | ===== Schémas ===== |
+ | {{:technique:archives:capture-simu-gns3.png?linkonly|:technique:archives:capture-simu-gns3.png}} | ||
+ | |||
+ | {{:technique:archives:capture-simu-gns3-ports.png}} | ||
===== Problématiques à envisager ===== | ===== Problématiques à envisager ===== | ||
Ligne 28: | Ligne 31: | ||
===== Solution en routage statique ===== | ===== Solution en routage statique ===== | ||
+ | ==== Configs ==== | ||
+ | <code text hosts> | ||
+ | 127.0.0.1 localhost | ||
+ | 192.168.90.222 rt_mitterand | ||
+ | 192.168.91.222 rt_zac | ||
+ | 6.5.4.1 rt_tls | ||
+ | </code> | ||
- | <code text rt_zac> | + | <code text rt_tls_network-interface> |
- | 127.0.0.1 | + | # The loopback network interface |
+ | auto lo | ||
+ | iface lo inet loopback | ||
+ | up ip addr add 6.5.4.1 dev $IFACE | ||
+ | |||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | # Pour les besoin de la simulation, NAT de mon aDSL, sinon rmmod iptables conseillé, cf h7 | ||
+ | address 192.168.1.42 | ||
+ | netmask 255.255.255.0 | ||
+ | gateway 192.168.1.254 | ||
+ | up sysctl -w net.ipv4.ip_forward=1 | ||
+ | up iptables -t nat -F POSTROUTING | ||
+ | up iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE | ||
+ | |||
+ | auto eth1 | ||
+ | iface eth1 inet static | ||
+ | address 192.168.90.223 | ||
+ | netmask 255.255.255.0 | ||
+ | up ip route add 6.5.4.0/24 via 192.168.90.222 | ||
+ | |||
+ | auto eth2 | ||
+ | iface eth2 inet static | ||
+ | address 192.168.91.223 | ||
+ | netmask 255.255.255.0 | ||
+ | up ip route add 6.5.5.0/24 via 192.168.91.222 | ||
</code> | </code> | ||
+ | |||
+ | <code text rt_mitterand_network-interface> | ||
+ | # The loopback network interface | ||
+ | auto lo | ||
+ | iface lo inet loopback | ||
+ | |||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address 192.168.90.222 | ||
+ | netmask 255.255.255.0 | ||
+ | gateway 192.168.90.223 | ||
+ | |||
+ | auto eth1 | ||
+ | iface eth1 inet static | ||
+ | address 172.16.0.1 | ||
+ | netmask 255.255.0.0 | ||
+ | |||
+ | #auto eth1:253 | ||
+ | iface eth1:253 inet static | ||
+ | address 172.16.0.253 | ||
+ | netmask 255.255.0.0 | ||
+ | up /root/setup_routing.sh | ||
+ | |||
+ | auto eth1:254 | ||
+ | iface eth1:254 inet static | ||
+ | address 172.16.0.254 | ||
+ | netmask 255.255.0.0 | ||
+ | up /root/setup_routing.sh | ||
+ | </code> | ||
+ | |||
+ | <code text rt_zac_network-interface> | ||
+ | # The loopback network interface | ||
+ | auto lo | ||
+ | iface lo inet loopback | ||
+ | |||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address 192.168.91.222 | ||
+ | netmask 255.255.255.0 | ||
+ | gateway 192.168.91.223 | ||
+ | up sysctl -w net.ipv4.ip_forward=1 | ||
+ | |||
+ | auto eth1 | ||
+ | iface eth1 inet static | ||
+ | address 172.16.0.2 | ||
+ | netmask 255.255.0.0 | ||
+ | |||
+ | auto eth1:253 | ||
+ | iface eth1:253 inet static | ||
+ | address 172.16.0.253 | ||
+ | netmask 255.255.0.0 | ||
+ | up /root/setup_routing.sh | ||
+ | |||
+ | #auto eth1:254 | ||
+ | iface eth1:254 inet static | ||
+ | address 172.16.0.254 | ||
+ | netmask 255.255.0.0 | ||
+ | up /root/setup_routing.sh | ||
+ | </code> | ||
+ | |||
+ | <code text adt1_network-interface> | ||
+ | # The loopback network interface | ||
+ | auto lo | ||
+ | iface lo inet loopback | ||
+ | |||
+ | # Simule l'antenne en bridge | ||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address 172.16.10.10 | ||
+ | netmask 255.255.0.0 | ||
+ | |||
+ | # Simule le routeur OpenWRT avec IP publiques | ||
+ | auto eth1 | ||
+ | iface eth1 inet static | ||
+ | address 6.5.4.10 | ||
+ | netmask 255.255.255.255 | ||
+ | up ip route replace default via 172.16.0.254 src 6.5.4.10 dev eth0 | ||
+ | up sysctl -w net.ipv4.ip_forward=1 | ||
+ | </code> | ||
+ | |||
+ | <code text adt2_network-interface> | ||
+ | # The loopback network interface | ||
+ | auto lo | ||
+ | iface lo inet loopback | ||
+ | |||
+ | # Simle l'antenne en bridge | ||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address 172.16.10.11 | ||
+ | netmask 255.255.0.0 | ||
+ | |||
+ | # Simule le routeur OpenWRT avec IP publiques | ||
+ | auto eth1 | ||
+ | iface eth1 inet static | ||
+ | address 6.5.5.10 | ||
+ | netmask 255.255.255.255 | ||
+ | up ip route replace default via 172.16.0.253 src 6.5.5.10 dev eth0 | ||
+ | up sysctl -w net.ipv4.ip_forward=1 | ||
+ | </code> | ||
+ | |||
+ | ==== Scripts ==== | ||
<code bash setup_routing.sh> | <code bash setup_routing.sh> | ||
#!/bin/bash | #!/bin/bash | ||
Ligne 42: | Ligne 178: | ||
ip4_public=$5 | ip4_public=$5 | ||
dev=eth1 | dev=eth1 | ||
+ | SELF=$(basename $0) | ||
+ | INFO="logger -p notice -t $SELF --" | ||
+ | CRIT="logger -p crit -t $SELF --" | ||
echo "$ip4_public ${adt_nom}.pub4 adt$adt_num" >> /etc/hosts.adt | echo "$ip4_public ${adt_nom}.pub4 adt$adt_num" >> /etc/hosts.adt | ||
Ligne 55: | Ligne 194: | ||
if [ $res2 -eq 0 ]; then | if [ $res2 -eq 0 ]; then | ||
if [ $res -eq 1 ]; then | if [ $res -eq 1 ]; then | ||
- | echo "Accès ajouté : adt $*" | + | $INFO "Accès ajouté : adt $*" |
fi | fi | ||
else | else | ||
- | echo -n "ERREUR : adt $adt_num $adt_etat $adt_nom : " | + | $CRIT "ERREUR : adt $adt_num $adt_etat $adt_nom : pb remplacement route : '$out'" |
- | echo "pb remplacement route : '$out'" | + | |
fi | fi | ||
;; | ;; | ||
Ligne 66: | Ligne 204: | ||
res=$? | res=$? | ||
case $res in | case $res in | ||
- | 0) echo "Accès supprimé : adt $*" ;; | + | 0) $INFO "Accès supprimé : adt $*" ;; |
2) : ;; # Route non trouvée, routage déjà supprimé | 2) : ;; # Route non trouvée, routage déjà supprimé | ||
- | *) echo -n "ERREUR : adt $adt_num $adt_etat $adt_nom : " | + | *) $CRIT "ERREUR : adt $adt_num $adt_etat $adt_nom : pb suppression route : '$out'" ;; |
- | echo "pb suppression route : '$out'" ;; | + | |
esac | esac | ||
;; | ;; | ||
*) | *) | ||
- | echo -n "ERREUR : adt $adt_num $adt_etat $adt_nom : " | + | $CRIT "ERREUR : adt $adt_num $adt_etat $adt_nom : '$adt_etat' n'est pas un état reconnu" |
- | echo "'$adt_etat' n'est pas un état reconnu" | + | |
;; | ;; | ||
esac | esac | ||
Ligne 89: | Ligne 225: | ||
</code> | </code> | ||
+ | <code bash config_adt.sh> | ||
+ | #!/bin/bash | ||
+ | # set ts=4 | ||
+ | # Généré le 2015-11-29 21:08:50+01:00 | ||
+ | |||
+ | #adt <num> <etat> <NOM_Prenom> <ip4_nexthop> <ip4_public> | ||
+ | adt 0001 actif Dxxxxx_Laurent 172.16.10.10 6.5.4.10 | ||
+ | adt 0002 actif Pxxxxx_Daniel 172.16.10.11 6.5.5.10 | ||
+ | #[...] | ||
+ | </code> | ||
+ | |||
+ | <code bash config_adt_gen.sh> | ||
+ | #!/bin/bash | ||
+ | SELF=$(basename $0) | ||
+ | INFO="logger -p notice -t $SELF --" | ||
+ | CRIT="logger -p crit -t $SELF --" | ||
+ | |||
+ | TMP=$(mktemp) | ||
+ | ssh automated@chd.sx sudo mysql --defaults-file=/etc/mysql/debian.cnf -BN -D gestion <<< 'SELECT * FROM v_config_adt;' >$TMP | ||
+ | |||
+ | if [ $? -eq 0 -a -s $TMP ] | ||
+ | then $INFO "Base de donnée lue avec succès" | ||
+ | else $CRIT "Echec de récupération des données depuis la base de données" | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | cat - $TMP >/root/config_adt.sh <<EOT | ||
+ | #!/bin/bash | ||
+ | # set ts=4 | ||
+ | # Généré le $DATE | ||
+ | |||
+ | #adt <num> <etat> <NOM_Prenom> <ip4_nexthop> <ip4_public> | ||
+ | EOT | ||
+ | rm $TMP | ||
+ | </code> | ||