---
title: "Configuration initiale routeur Cisco"
domain: network
subdomain: routing
type: snippet
tags: [cisco, router, initial-config, dhcp, ip-sla, tracking, ios, interface]
difficulty: beginner
status: stable
updated: "2025-05-14"
---
## Config de base

La séquence hostname / enable secret / SSH / VTY / NTP / syslog est identique à celle du switch.
Voir `network/switching/03-switch-init` pour le détail complet.

---

## Configuration des interfaces

### Interface physique

```text
interface GigabitEthernet0/0
 description {{DESCRIPTION}}
 ip address {{IP}} {{MASK}}
 no shutdown
```

### Sous-interface (Router-on-a-Stick / ROAS)

```text
interface GigabitEthernet0/0
 no shutdown

interface GigabitEthernet0/0.10
 description VLAN10-DATA
 encapsulation dot1Q 10
 ip address {{IP_VLAN10}} {{MASK}}

interface GigabitEthernet0/0.20
 description VLAN20-VOIP
 encapsulation dot1Q 20
 ip address {{IP_VLAN20}} {{MASK}}

! dot1Q native VLAN (non taggué)
interface GigabitEthernet0/0.1
 encapsulation dot1Q 1 native
```

### Loopback

```text
! Stable pour management SSH et router-id OSPF/BGP — ne tombe jamais
interface Loopback0
 description MANAGEMENT
 ip address {{LOOPBACK_IP}} 255.255.255.255
```

### Vérification interfaces

```text
show interfaces
show ip interface brief
show interfaces GigabitEthernet0/0
show interfaces status
```

---

## DHCP Serveur

### Configuration pool DHCP

```text
! Exclure IPs fixes (passerelle, serveurs, imprimantes)
ip dhcp excluded-address {{RANGE_START}} {{RANGE_END}}

ip dhcp pool {{POOL_NAME}}
 network {{NET}} {{MASK}}
 default-router {{GW_IP}}
 dns-server {{DNS1}} {{DNS2}}
 domain-name {{DOMAIN}}
 lease 7
```

### DHCP Relay (ip helper-address)

```text
! Sur l'interface côté clients, relayer vers serveur DHCP distant
interface {{CLIENT_INTERFACE}}
 ip helper-address {{DHCP_SERVER_IP}}
```

### Vérification DHCP

```text
show ip dhcp binding
show ip dhcp pool
show ip dhcp conflict
show ip dhcp statistics
! Supprimer les conflits
clear ip dhcp conflict *
```

---

## IP SLA + Object Tracking (dual-WAN / failover)

### IP SLA — sonde de disponibilité

```text
ip sla 1
 icmp-echo {{TARGET_IP}} source-interface GigabitEthernet0/0
 frequency 10
ip sla schedule 1 life forever start-time now

! Sonde HTTP optionnelle
ip sla 2
 http get http://{{TARGET_URL}} source-interface GigabitEthernet0/1
 frequency 30
ip sla schedule 2 life forever start-time now
```

### Object Tracking

```text
track 1 ip sla 1 reachability
 delay down 15 up 10
```

### Floating static route avec tracking

```text
! Route principale (WAN1) — AD 1 (défaut)
ip route 0.0.0.0 0.0.0.0 {{GW_WAN1}}

! Route de secours (WAN2) — AD 10, active seulement si track 1 est down
ip route 0.0.0.0 0.0.0.0 {{GW_WAN2}} 10 track 1
```

### Vérification IP SLA et Tracking

```text
show ip sla statistics
show ip sla statistics 1
show track
show track 1
show ip route
```

---

## Sauvegarde configuration

### Vers TFTP

```text
! Sauvegarder la running-config
copy running-config tftp://{{TFTP_SERVER}}/{{HOSTNAME}}.cfg

! Restaurer depuis TFTP
copy tftp://{{TFTP_SERVER}}/backup.cfg running-config
```

### Vers FTP

```text
ip ftp username {{FTP_USER}}
ip ftp password {{FTP_PASS}}
copy running-config ftp://{{FTP_SERVER}}/{{HOSTNAME}}.cfg
```

### Sauvegarde locale

```text
! Sauvegarder sous un nom alternatif en flash
copy running-config flash:{{HOSTNAME}}-backup.cfg
dir flash:
```

---

## Checklist de configuration routeur

<Checklist
  storageKey="net-router-init"
  items={[
    "Hostname configuré",
    "SSH configuré (domaine + RSA 2048 + version 2)",
    "VTY restreint à SSH, login local",
    "Interfaces physiques et loopback configurées et up",
    "Routes vérifiées (show ip route)",
    "DHCP configuré si rôle de serveur DHCP",
    "IP SLA configuré si dual-WAN ou failover",
    "Object tracking lié aux routes flottantes",
    "NTP synchronisé",
    "Syslog vers serveur centralisé",
    "write memory effectué"
  ]}
/>

<Tip>
Toujours configurer une interface Loopback0 pour le management SSH et comme router-id OSPF/BGP. Contrairement aux interfaces physiques, une Loopback ne peut pas tomber (link-down) — elle reste up tant que le routeur fonctionne, garantissant un point d'accès SSH stable même en cas de perte d'un lien physique.
</Tip>
