PROJET AUTOBLOG


Planet-Libre

source: Planet-Libre

⇐ retour index

bazzanella : serveur avec plusieurs passerelles

dimanche 20 octobre 2013 à 16:15

Vous 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
  1. # The loopback network interface
  2. auto lo
  3. iface lo inet loopback
  4.  
  5. # The network 0 interface
  6. auto eth0
  7. iface eth0 inet static
  8.         address 192.168.0.1
  9.         netmask 255.255.255.0
  10.         broadcast 192.168.0.255
  11.         network 192.168.0.0
  12.         gateway 192.168.0.254
  13.         up /sbin/ip route add default via 192.168.0.254 dev eth0 table network0
  14.         up /sbin/ip rule add from 192.168.0.0/24 table  network0
  15.         post-down /sbin/ip rule del from 192.168.0.0/24 table  network0
  16.         post-down /sbin/ip route del default via 192.168.0.254 dev eth0 table  network0
  17.         # dns-* options are implemented by the resolvconf package, if installed
  18.         ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS
  19.         dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4
  20.         dns-domain yourdomain.tld
  21.         dns-search yourdomain.tld
  22.  
  23. auto eth0:0
  24.           iface eth0:0 inet static
  25.           address 192.168.0.2
  26.           netmask 255.255.255.0
  27.  
  28. auto eth0:1
  29.           iface eth0:1 inet static
  30.           address 192.168.0.3
  31.           netmask 255.255.255.0
  32.  
  33. # The network 1 interface
  34. auto eth1
  35. iface eth1 inet static
  36.         address 192.168.1.1
  37.         netmask 255.255.255.0
  38.         broadcast 192.168.1.255
  39.         network 192.168.1.0
  40.         ### gateway 192.168.1.254
  41.         up /sbin/ip route add default via 192.168.1.254 dev eth1 table network1
  42.         up /sbin/ip rule add from 192.168.1.0/24 table  network1
  43.         post-down /sbin/ip rule del from 192.168.1.0/24 table  network1
  44.         post-down /sbin/ip route del default via 192.168.1.254 dev eth1 table  network1
  45.         # dns-* options are implemented by the resolvconf package, if installed
  46.         ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS
  47.         dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4
  48.         dns-domain yourdomain.tld
  49.         dns-search yourdomain.tld
  50.  
  51. auto eth1:0
  52.           iface eth1:0 inet static
  53.           address 192.168.1.2
  54.           netmask 255.255.255.0
  55.  
  56. auto eth1:1
  57.           iface eth1:1 inet static
  58.           address 192.168.1.3
  59.           netmask 255.255.255.0
  60.  
  61. # The network 2 interface
  62. auto eth2
  63. iface eth1 inet static
  64.         address 192.168.2.1
  65.         netmask 255.255.255.0
  66.         broadcast 192.168.2.255
  67.         network 192.168.2.0
  68.         ### gateway 192.168.2.254
  69.         up /sbin/ip route add default via 192.168.2.254 dev eth2 table network2
  70.         up /sbin/ip rule add from 192.168.2.0/24 table  network2
  71.         post-down /sbin/ip rule del from 192.168.2.0/24 table  network2
  72.         post-down /sbin/ip route del default via 192.168.2.254 dev eth2 table  network2
  73.         # dns-* options are implemented by the resolvconf package, if installed
  74.         ### Z1.Z2.Z3.Z4 U1.U2.U3.U4 : Les IPs de vos serveurs DNS
  75.         dns-nameservers Z1.Z2.Z3.Z4 U1.U2.U3.U4
  76.         dns-domain yourdomain.tld
  77.         dns-search yourdomain.tld
  78.  
  79. auto eth2:0
  80.           iface eth2:0 inet static
  81.           address 192.168.2.2
  82.           netmask 255.255.255.0
  83.  
  84. auto eth2:1
  85.           iface eth2:1 inet static
  86.           address 192.168.2.3
  87.           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 :)

Twitt

Gravatar de bazzanella
Original post of bazzanella.Votez pour ce billet sur Planet Libre.