• # Un autre exemple en production :

    Posté par (site web personnel) . En réponse au message Routage inter vlans. Évalué à 1.

    Voici un exemple actuellement en production dans la société ou je travaille :

    Init bsd sur slackware ...

    Fichier /etc/rc.d/rc.vlan :

    #!/bin/sh

    echo "Bringing up vlan's ..."

    /sbin/ifconfig eth0 down
    /sbin/ifconfig eth0 0.0.0.0 up

    # Campo-12 vlan
    /sbin/vconfig add eth0 30

    # Campo-30 vlan
    /sbin/vconfig add eth0 40

    # Chevaleret vlan
    /sbin/vconfig add eth0 50

    # Tolbiac vlan
    /sbin/vconfig add eth0 60

    # Activating Campo-12 vlan
    /sbin/ifconfig eth0.30 10.1.3.253 netmask 255.255.255.0 broadcast 10.1.3.255 up

    # Activating Campo-30 vlan
    /sbin/ifconfig eth0.40 10.1.2.254 netmask 255.255.255.0 broadcast 10.1.2.255 up

    # Activating Chevaleret vlan
    /sbin/ifconfig eth0.50 10.1.4.254 netmask 255.255.255.0 broadcast 10.1.4.255 up

    # Activating Tolbiac vlan
    /sbin/ifconfig eth0.60 10.1.6.254 netmask 255.255.255.0 broadcast 10.1.6.255 up

    # Adding routes to others subnets
    /sbin/route add -net 10.1.1.0 netmask 255.255.255.0 gw 10.1.3.254
    /sbin/route add -net 10.1.5.0 netmask 255.255.255.0 gw 10.1.3.254
    /sbin/route add default gw 10.1.4.253

    echo "Done ..."

    # End vlan

    --------------------------------------------------------------------------------------------

    Les interfaces :

    root@rtr-mikli:~# ifconfig
    eth0 Link encap:Ethernet HWaddr 00:B0:D0:EC:E1:16
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:2423877795 errors:0 dropped:0 overruns:325 frame:0
    TX packets:1824982882 errors:0 dropped:0 overruns:0 carrier:17061
    collisions:0 txqueuelen:1000
    RX bytes:981160989 (935.7 Mb) TX bytes:1223687604 (1166.9 Mb)
    Interrupt:5 Base address:0xec80

    eth0.30 Link encap:Ethernet HWaddr 00:B0:D0:EC:E1:16
    inet addr:10.1.3.253 Bcast:10.1.3.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:995157421 errors:0 dropped:0 overruns:0 frame:0
    TX packets:620940096 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:3267048197 (3115.6 Mb) TX bytes:3254979621 (3104.1 Mb)

    eth0.40 Link encap:Ethernet HWaddr 00:B0:D0:EC:E1:16
    inet addr:10.1.2.254 Bcast:10.1.2.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:158494634 errors:0 dropped:0 overruns:0 frame:0
    TX packets:136381530 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:835029664 (796.3 Mb) TX bytes:2983220638 (2845.0 Mb)

    eth0.50 Link encap:Ethernet HWaddr 00:B0:D0:EC:E1:16
    inet addr:10.1.4.254 Bcast:10.1.4.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:732130423 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1067293605 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:2610077458 (2489.1 Mb) TX bytes:1845438329 (1759.9 Mb)

    eth0.60 Link encap:Ethernet HWaddr 00:B0:D0:EC:E1:16
    inet addr:10.1.6.254 Bcast:10.1.6.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:245081 errors:0 dropped:0 overruns:0 frame:0
    TX packets:363173 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:17168964 (16.3 Mb) TX bytes:341473843 (325.6 Mb)

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:371295 errors:0 dropped:0 overruns:0 frame:0
    TX packets:371295 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:42274973 (40.3 Mb) TX bytes:42274973 (40.3 Mb)

    --------------------------------------------------------------------------------------------

    Résultat de route :

    root@rtr-mikli:~# route
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    network-10-1-4- * 255.255.255.0 U 0 0 0 eth0.50
    network-10-1-5- rtr0-francetele 255.255.255.0 UG 0 0 0 eth0.30
    network-10-1-6- * 255.255.255.0 U 0 0 0 eth0.60
    network-10-1-1- rtr0-francetele 255.255.255.0 UG 0 0 0 eth0.30
    network-10-1-2- * 255.255.255.0 U 0 0 0 eth0.40
    network-10-1-3- * 255.255.255.0 U 0 0 0 eth0.30
    loopback * 255.0.0.0 U 0 0 0 lo
    default internet-gw.par 0.0.0.0 UG 0 0 0 eth0.50

    --------------------------------------------------------------------------------------------

    résultat de ip -r route :

    root@rtr-mikli:~# ip -r route
    10.1.4.0/24 dev eth0.50 proto kernel scope link src 10.1.4.254
    10.1.5.0/24 via rtr0-francetelecom.paris-campo-12.mikli.france dev eth0.30
    10.1.6.0/24 dev eth0.60 proto kernel scope link src 10.1.6.254
    10.1.1.0/24 via rtr0-francetelecom.paris-campo-12.mikli.france dev eth0.30
    10.1.2.0/24 dev eth0.40 proto kernel scope link src 10.1.2.254
    10.1.3.0/24 dev eth0.30 proto kernel scope link src 10.1.3.253
    127.0.0.0/8 dev lo scope link
    default via internet-gw.paris-chevaleret.mikli.france dev eth0.50

    Bien faire attention au niveau du switch à la configuration Egress Ports / Forbidden Egress Ports / Untagged Ports (isolation des vlan's) ...

    A++