--- title: "Switch" date: 2025-01-24 lastmod: 2025-01-24 publishdate: 2025-01-24 draft: false description: "Commande spécifique pour les switchs" keyword: ["cisco","switch"] weight: 20 --- ## Configurer la SVI (Switch Virtual Interface) Switch(conf)# interface vlan1 Switch(conf-if)# ip address A.B.C.D M1.M2.M3.M4 Switch(conf-if)# no shutdown ## mettre en place une passerelle par défaut sur un switch Switch(conf)# ip default-gateway A.B.C.D Configuration Vlan sur un Switch ================================ ## Définir un Vlan Switch> enable Switch# configure terminal Switch(conf)# vlan *numero Vlan* Switch(conf-vlan)# name *nom* Switch(conf-vlan)# exit Switch(conf)# ## Rattacher un port à un VLAN Switch> enable Switch# configure terminal Switch(conf)# interface *interface* Switch(conf-if)# switchport mode access Switch(conf-if)# switchport access vlan *numero Vlan* Switch(conf-if)# exit Switch(conf)# ## Rattacher un ensemble de ports à un VLAN Switch> enable Switch# configure terminal Switch(conf)# interface range *1ère interface* - *dernière interface* Switch(conf-if)# switchport mode access Switch(conf-if)# switchport access vlan *numero Vlan* Switch(conf-if)# exit Switch(conf)# ## Configurer un port en mode TRUNK Le mode TRUNK permet a plusieurs vlan de passer par le même port Switch> enable Switch# configure terminal Switch(conf)# interface *interface* Switch(conf-if)# switchport mode trunk Switch(conf-if)# switchport trunk allowed vlan *Vlan1* [,*VLan2*] Switch(conf-if)# exit Switch(conf)# ## activation du routage entre les VLANs si switch niveau 3 attriber des adresse ip au vlan et les déclarer en passerelles dans les hôtes connectés Switch> enable Switch# configure terminal Switch(conf)# ip routing Configuration Security port =========================== Switch> enable Switch# configure terminal Switch(conf)# interface *interface* Switch(conf-if)# switchport mode access Switch(conf-if)# switchport port-security Switch(conf-if)# switchport port-security maximum *nb de tentative* Switch(conf-if)# switchport port-security mac-address {sticky|*MAC*} Switch(conf-if)# switchport port-security violation {protect|restrict|shutdown}