Skip to main content

00 - Commande_switch_basique

1) sécurisation

Switch(config)# enable password <votre mot de passe> (stocké en clair dans la configuration : show running-config)
Switch(config)# enable secret <votre mot de passe> (hash visible dans la configuration : secret5)


// Mettre en place une authentification à la connexion

Switch(config)#line con 0
Switch(config-line)#password cisco
Switch(config-line)#login

Switch(config)#service password-encryption // Masquer les mots de passe de connexion dans la configuration
Switch(config)#banner motd # <message> #

2 ) commande de configuration plan réseau

switch(config)# hostname S3   // change le nom du switch
S3(config)# interface vlan 10   // ajout du vlan 10
Switch3(config-if)# ip address 192.168.10.0 255.255.255.192   // attribution de l'ip et du masque 

3) Commande de visualisation / sauvegarde

show running-config  // elle fournit la pluspart des informations sur le commutateur
do show run  // examiner la configuration
do show vlan  // consulter tout les vlans
do show ip interface brief
copy running-config startup-config //Elle sauvegarde la configuration actuelle pour qu’elle soit conservée même après un redémarrage.
show interfaces status  //affiche le statut des interfaces
show interface fastEthernet 0/X // affiche des informations sur l’interface spécifiée
show interfaces trunk // affiche les interfaces de type trunk et les VLAN transitant sur celles-ci
show spanning-tree (interface fa0/x // vlan x) // affiche les informations à propos du protocole spanning tree

4) exportation configuration en texte

//Exporter la configuration vers un fichier texte par tftp (running / startup config)

SW3#copy running-config tftp
Address or name of remote host []? 10.10.0.2
Destination filename [SW50-confg]?
Writing running-config....!!
[OK - 1120 bytes]
1120 bytes copied in 3.008 secs (372 bytes/sec)

//Importer la configuration depuis un fichier texte par tftp vers run ou startup config :

SW3#copy tftp running-config
Address or name of remote host []? 10.10.0.2
Source filename []? SW50-confg
Destination filename [running-config]? running-config
Accessing tftp://10.10.0.2/SW50-confg...
Loading SW50-confg from 10.10.0.2: !
[OK - 1120 bytes]
1120 bytes copied in 0.006 secs (186666 bytes/sec)

5) étapes configuration switch

1) Sécurisation accès au switch

hostname SW-XXX
no ip domain-lookup
enable secret <motdepasse>
service password-encryption
banner motd # Accès strictement réservé #
username admin secret <motdepasse>

2) Configuration vlan / lan

- Création de vlan
- paramétrages vlan
- gateway

3) Configuration des ports

- Switchport mode access
- Trunk
- Spanning-tree

4) sécurité avancée

- DHCP Snooping
- Protection STP

5) ACL

- Acl restriction ssh
- Acl bloquage

6) SYSLOG, NTP (raphael)

7) Vérification / Sauvegarde

6) script entier

switch(config)# hostname S1

cata-x(config)#line vty 0 15
cata-x(config-line)#password cataclysmique2
cata-x(config-line)#login


cata-x(config)#line console 0
cata-x(config-line)#password cataclysmique
cata-x(config-line)#login

cata-x(config)#enable secret cataclysmique3
cata-x(config)#service password-encryption

no ip domain-lookup
banner motd # Accès strictement réservé #

S1(config)# interface vlan 10   
Switch3(config-if)# ip address 192.168.10.1 255.255.255.192   
Switch3(config-if)# no shutdown

Switch3(config-if)#interface range FastEthernet0/1 - 5
Switch3(config-if)#switchport mode access
Switch3(config-if)#switchport access vlan 10
Switch3(config-if)#spanning-tree portfast
Switch3(config-if)#spanning-tree bpduguard enable

7 ) configurer le port trunk:

// exemple

interface fastEthernet0/1
switchport mode trunk
switchport trunk allowed vlan 10,20,30,40,50,60
end

8) Nommage des vlans:


 

vlan 10
name Fabrication_Maintenance
exit

vlan 20
name Gestion_Admin_Direction_Stock
exit

vlan 30
name Commercial_Etudes
exit

vlan 40
name Visiteurs
exit

vlan 50
name cameras
exit

vlan 60 
name arduino
exit