bazzanella : serveur avec plusieurs passerelles
dimanche 20 octobre 2013 à 16:15Vous avez un serveur web mutualisé accueillant plusieurs sites Internet dont certains possèdent une ip dédiée, derrière une architecture VLAN.
Pour ne pas avoir de soucis de routage, voici un exemple de configuration optimale et opérationnelle en production, permettant une isolation totale entre différents réseaux. Votre serveur dispose d’une carte réseau (physique ou virtuelle) par interface.
Vous pouvez adapter les adressages pour des réseaux privés ou publics au gré de vos besoins.
# The loopback network interface auto lo iface lo inet loopback # The network 0 interface auto eth0 iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 network 192.168.0.0 gateway 192.168.0.254 up /sbin/ip route add default via 192.168.0.254 dev eth0 table network0 up /sbin/ip rule add from 192.168.0.0/24 table network0 post-down /sbin/ip rule del from 192.168.0.0/24 table network0 post-down /sbin/ip route del default via 192.168.0.254 dev eth0 table network0 # dns-* options are implemented by the resolvconf package, if installed ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4 dns-domain yourdomain.tld dns-search yourdomain.tld auto eth0:0 iface eth0:0 inet static address 192.168.0.2 netmask 255.255.255.0 auto eth0:1 iface eth0:1 inet static address 192.168.0.3 netmask 255.255.255.0 # The network 1 interface auto eth1 iface eth1 inet static address 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 network 192.168.1.0 ### gateway 192.168.1.254 up /sbin/ip route add default via 192.168.1.254 dev eth1 table network1 up /sbin/ip rule add from 192.168.1.0/24 table network1 post-down /sbin/ip rule del from 192.168.1.0/24 table network1 post-down /sbin/ip route del default via 192.168.1.254 dev eth1 table network1 # dns-* options are implemented by the resolvconf package, if installed ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4 dns-domain yourdomain.tld dns-search yourdomain.tld auto eth1:0 iface eth1:0 inet static address 192.168.1.2 netmask 255.255.255.0 auto eth1:1 iface eth1:1 inet static address 192.168.1.3 netmask 255.255.255.0 # The network 2 interface auto eth2 iface eth1 inet static address 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255 network 192.168.2.0 ### gateway 192.168.2.254 up /sbin/ip route add default via 192.168.2.254 dev eth2 table network2 up /sbin/ip rule add from 192.168.2.0/24 table network2 post-down /sbin/ip rule del from 192.168.2.0/24 table network2 post-down /sbin/ip route del default via 192.168.2.254 dev eth2 table network2 # dns-* options are implemented by the resolvconf package, if installed ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4 dns-domain yourdomain.tld dns-search yourdomain.tld auto eth2:0 iface eth2:0 inet static address 192.168.2.2 netmask 255.255.255.0 auto eth2:1 iface eth2:1 inet static address 192.168.2.3 netmask 255.255.255.0
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The network 0 interface
- auto eth0
- iface eth0 inet static
- address 192.168.0.1
- netmask 255.255.255.0
- broadcast 192.168.0.255
- network 192.168.0.0
- gateway 192.168.0.254
- up /sbin/ip route add default via 192.168.0.254 dev eth0 table network0
- up /sbin/ip rule add from 192.168.0.0/24 table network0
- post-down /sbin/ip rule del from 192.168.0.0/24 table network0
- post-down /sbin/ip route del default via 192.168.0.254 dev eth0 table network0
- # dns-* options are implemented by the resolvconf package, if installed
- ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS
- dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4
- dns-domain yourdomain.tld
- dns-search yourdomain.tld
- auto eth0:0
- iface eth0:0 inet static
- address 192.168.0.2
- netmask 255.255.255.0
- auto eth0:1
- iface eth0:1 inet static
- address 192.168.0.3
- netmask 255.255.255.0
- # The network 1 interface
- auto eth1
- iface eth1 inet static
- address 192.168.1.1
- netmask 255.255.255.0
- broadcast 192.168.1.255
- network 192.168.1.0
- ### gateway 192.168.1.254
- up /sbin/ip route add default via 192.168.1.254 dev eth1 table network1
- up /sbin/ip rule add from 192.168.1.0/24 table network1
- post-down /sbin/ip rule del from 192.168.1.0/24 table network1
- post-down /sbin/ip route del default via 192.168.1.254 dev eth1 table network1
- # dns-* options are implemented by the resolvconf package, if installed
- ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS
- dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4
- dns-domain yourdomain.tld
- dns-search yourdomain.tld
- auto eth1:0
- iface eth1:0 inet static
- address 192.168.1.2
- netmask 255.255.255.0
- auto eth1:1
- iface eth1:1 inet static
- address 192.168.1.3
- netmask 255.255.255.0
- # The network 2 interface
- auto eth2
- iface eth1 inet static
- address 192.168.2.1
- netmask 255.255.255.0
- broadcast 192.168.2.255
- network 192.168.2.0
- ### gateway 192.168.2.254
- up /sbin/ip route add default via 192.168.2.254 dev eth2 table network2
- up /sbin/ip rule add from 192.168.2.0/24 table network2
- post-down /sbin/ip rule del from 192.168.2.0/24 table network2
- post-down /sbin/ip route del default via 192.168.2.254 dev eth2 table network2
- # dns-* options are implemented by the resolvconf package, if installed
- ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS
- dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4
- dns-domain yourdomain.tld
- dns-search yourdomain.tld
- auto eth2:0
- iface eth2:0 inet static
- address 192.168.2.2
- netmask 255.255.255.0
- auto eth2:1
- iface eth2:1 inet static
- address 192.168.2.3
- netmask 255.255.255.0
Pour un question de clarté, je vous conseille vivement de spécifier les paramètres de masque, de réseau et de diffusion et la passerelle cible en commentaire.
Remerciements: Loic.d pour ses conseils, son expertise et sa patience. Il se reconnaîtra
Original post of bazzanella.Votez pour ce billet sur Planet Libre.