🔭 Modele OSI (7 couches)
7. Application HTTP, DNS, SSH
6. Presentation SSL/TLS, JPEG
5. Session NetBIOS, RPC
4. Transport TCP, UDP (Ports)
3. Network IP, ICMP (Routeurs)
2. Data Link Ethernet, MAC (Switch)
1. Physical Cables, Bits (Hub)
Memo: "Please Do Not Throw
Sausage Pizza Away"
🔗 TCP vs UDP
| TCP | UDP |
| Fiable (ACK) | Non fiable |
| Ordonne | Non ordonne |
| Connexion | Sans connexion |
| Lent | Rapide |
| HTTP, SSH, Email | DNS, Video, Gaming |
3-Way Handshake TCP:
Client --> SYN --> Serveur
Client <-- SYN+ACK <-- Serveur
Client --> ACK --> Serveur
[Connexion etablie]
🔌 Ports importants
| Port | Service |
| 20/21 | FTP |
| 22 | SSH |
| 23 | Telnet (obsolete) |
| 25 | SMTP (email) |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 3306 | MySQL |
| 5432 | PostgreSQL |
| 6379 | Redis |
| 8080 | HTTP Alt |
| 9090 | Prometheus |
| 3000 | Grafana |
🌐 Adressage IP
Classes IP privees:
| Classe | Plage | CIDR |
| A | 10.0.0.0 - 10.255.255.255 | /8 |
| B | 172.16.0.0 - 172.31.255.255 | /12 |
| C | 192.168.0.0 - 192.168.255.255 | /16 |
CIDR courants:
| CIDR | Masque | Hosts |
| /8 | 255.0.0.0 | 16M |
| /16 | 255.255.0.0 | 65K |
| /24 | 255.255.255.0 | 254 |
| /28 | 255.255.255.240 | 14 |
| /32 | 255.255.255.255 | 1 |
🌐 DNS
Types d'enregistrements:
| Type | Usage |
| A | Domaine -> IPv4 |
| AAAA | Domaine -> IPv6 |
| CNAME | Alias vers autre domaine |
| MX | Serveur mail |
| TXT | Texte (SPF, DKIM) |
| NS | Serveur DNS |
| PTR | IP -> Domaine (reverse) |
dig example.com A
dig example.com MX
nslookup example.com
🔌 Commandes Reseau
ip addrVoir IPs
ip routeTable routage
ss -tulpnPorts ecoute
ping hostTest connectivite
traceroute hostRoute vers host
mtr hostping + traceroute
dig domainRequete DNS
nslookup domainLookup DNS
curl -I urlHeaders HTTP
tcpdump -i eth0Capture paquets
nc -zv host portTest port TCP
🔒 Triade CIA
Confidentiality
(Chiffrement)
/\
/ \
/ \
Integrity -- Availability
(Hashing) (Redundance)
| Principe | Protection |
| Confidentialite | Chiffrement, ACL |
| Integrite | Hash, signatures |
| Disponibilite | HA, backups, DR |
🛡 Firewall (iptables)
iptables -L -n -v
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s 1.2.3.4 -j DROP
iptables -A INPUT -m state \
--state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -j DROP
iptables-save > /etc/iptables.rules
firewalld (RHEL/CentOS):
firewall-cmd --list-all
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload
🔎 IDS vs IPS
| IDS | IPS |
| Detection | Prevention |
| Passif (copie trafic) | Inline (bloque) |
| Alerte seulement | Bloque + alerte |
| Snort, Suricata | Snort inline, Fail2ban |
Detection:
- Signature - Patterns connus
- Anomalie - Ecart du normal
- Heuristique - Comportement suspect
🔒 VPN Protocols
| Protocol | Port | Notes |
| OpenVPN | 1194/UDP | Open source, flexible |
| WireGuard | 51820/UDP | Moderne, rapide |
| IPSec | 500,4500/UDP | Standard entreprise |
| L2TP | 1701/UDP | Avec IPSec |
🔐 SSH Hardening
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
Port 2222
MaxAuthTries 3
AllowUsers azureuser admin
Protocol 2
ssh-keygen -t ed25519Generer cle
ssh-copy-id user@hostCopier cle pub
📈 Stack Monitoring
+------------------+
| GRAFANA | Visualisation
| (port 3000) |
+--------+---------+
|
+--------v---------+
| PROMETHEUS | Metriques
| (port 9090) | (time-series)
+--------+---------+
|
+----+----+
| |
+---v---+ +---v---+
| Node | | App | Exporters
|Exporter| |Metrics|
+-------+ +-------+
📊 Prometheus / PromQL
100 - (avg(irate(node_cpu_seconds_total
{mode="idle"}[5m])) * 100)
(1 - (node_memory_MemAvailable_bytes /
node_memory_MemTotal_bytes)) * 100
100 - ((node_filesystem_avail_bytes
/ node_filesystem_size_bytes) * 100)
rate(http_requests_total[5m])
rate(http_requests_total{status=~"5.."}[5m])
📝 Logging (ELK)
+-------------+
| KIBANA | Visualisation
| (port 5601) |
+------+------+
|
+------v------+
|ELASTICSEARCH| Stockage/Recherche
| (port 9200) |
+------+------+
|
+------v------+
| LOGSTASH | Processing
| (port 5044) |
+------+------+
|
[LOGS]
Fichiers logs Linux:
/var/log/messagesSysteme
/var/log/secureAuth SSH
/var/log/nginx/Nginx
journalctl -u svcSystemd
🔔 Alerting
Metriques cles (USE):
| Metrique | Seuil typique |
| CPU | > 80% pendant 5min |
| Memory | > 90% |
| Disk | > 85% |
| Load avg | > nb CPUs |
| Error rate | > 1% |
| Latency p99 | > 500ms |
Outils:
- Alertmanager (Prometheus)
- PagerDuty, OpsGenie
- Slack, Email webhooks
🎯 SLI / SLO / SLA
| Terme | Definition | Exemple |
| SLI |
Service Level Indicator (metrique) |
Latency p99 |
| SLO |
Service Level Objective (cible) |
p99 < 200ms |
| SLA |
Service Level Agreement (contrat) |
99.9% uptime |
Les "Nines":
| Uptime | Downtime/an |
| 99% | 3.65 jours |
| 99.9% | 8.76 heures |
| 99.99% | 52.6 minutes |
| 99.999% | 5.26 minutes |