0Pricing
Linux Networking & TCP/IP for Developers · Leçon

Gestion des interfaces réseau

Configurez et gérez les interfaces réseau à l’aide d’outils comme `ip` et comprenez les fichiers de configuration réseau persistante.

Gestion des interfaces réseau est une leçon Linux Networking & TCP/IP for Developers gratuite sur CoddyKit. Ceci est la leçon 1 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Linux Networking & TCP/IP for Developers, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Linux Networking & TCP/IP for Developers comprend 4 leçons au total.

Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.

What are Network Interfaces?

Think of your computer's network interface as its "ID card" for communicating on a network. It's the hardware or software component that allows your device to connect to a network, whether wired (Ethernet) or wireless (Wi-Fi).

Every network interaction, like browsing a website or sending an email, goes through one of these interfaces.

Discovering Your Interfaces

The first step in managing interfaces is knowing which ones you have! The ip command is your primary tool in modern Linux systems. Use ip link show to list all network interfaces.

You'll often see interfaces like lo (loopback), eth0 (Ethernet), or wlan0 (Wi-Fi).

ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:00:00:01 brd ff:ff:ff:ff:ff:ff

Decoding Interface Details

Let's break down the ip link show output:

  • lo: The loopback interface, used for internal communication.
  • eth0: A common name for the first Ethernet adapter.
  • UP: Indicates the interface is active.
  • mtu: Maximum Transmission Unit, the largest packet size it can handle.
  • link/ether: Shows the MAC address, a unique hardware identifier.

Activating & Deactivating Interfaces

You can enable or disable network interfaces. Disabling an interface effectively takes it offline, preventing any network traffic through it. This is useful for troubleshooting or security.

Use ip link set dev [interface_name] up to enable and down to disable.

# Bring eth0 down
ip link set dev eth0 down

# Bring eth0 up
ip link set dev eth0 up

Checking Interface IP Addresses

While ip link show gives you physical layer info, you need ip addr show (or ip a for short) to see IP addresses assigned to interfaces. This command reveals Layer 3 (Network Layer) details.

An IP address allows your device to be located and communicate with other devices on a network.

ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:00:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 86290sec preferred_lft 86290sec
    inet6 fe80::a00:27ff:fe00:1%eth0/64 scope link
       valid_lft forever preferred_lft forever

Assigning IP Addresses Temporarily

You can assign an IP address to an interface on the fly using ip addr add. This change is temporary and will be lost upon reboot or network service restart.

The format is ip addr add [IP_address]/[CIDR_prefix] dev [interface_name].

# Add IP 192.168.2.10/24 to eth0
ip addr add 192.168.2.10/24 dev eth0

# Verify it's added
ip addr show eth0

Removing Temporary IP Addresses

Just as you can add an IP address, you can also remove it. This is useful if you've made a mistake or need to reconfigure an interface's addressing.

Use ip addr del [IP_address]/[CIDR_prefix] dev [interface_name] to remove an address.

# Remove IP 192.168.2.10/24 from eth0
ip addr del 192.168.2.10/24 dev eth0

# Verify it's gone
ip addr show eth0

The Need for Permanent Settings

The ip commands we've used so far apply changes immediately, but these changes are not persistent. This means they will be lost when the system reboots or the network service restarts.

For a stable network setup, you need to save your configurations in specific files or through a network management service.

Making Changes Permanent

Linux distributions typically use configuration files to store network settings persistently. The exact location and format can vary, but common approaches include:

  • Debian/Ubuntu: /etc/network/interfaces
  • CentOS/RHEL: Files in /etc/sysconfig/network-scripts/
  • Modern systems: NetworkManager or Netplan configurations (e.g., .yaml files in /etc/netplan/)

These files are read at boot time or when network services are restarted.

Interface Management Check

You've learned how to inspect and temporarily modify network interfaces using the ip command. Let's test your understanding.

Recap: Managing Network Interfaces

In this lesson, you learned how to manage Linux network interfaces using the powerful ip command. We covered:

  • Listing interfaces with ip link show.
  • Activating/deactivating interfaces with ip link set.
  • Viewing and assigning temporary IP addresses with ip addr.
  • The importance of persistent configuration files for permanent changes.

Mastering these commands is crucial for any Linux network administrator or developer!

Questions Fréquemment Posées

La leçon « Gestion des interfaces réseau » est-elle gratuite ?

Oui — le texte complet de « Gestion des interfaces réseau » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Linux Networking & TCP/IP for Developers, passe à CoddyKit PRO. Le cours Linux Networking & TCP/IP for Developers comprend 4 leçons au total.

Qu'est-ce que j'apprendrai dans « Gestion des interfaces réseau » ?

Configurez et gérez les interfaces réseau à l’aide d’outils comme `ip` et comprenez les fichiers de configuration réseau persistante. Tu pratiques Linux Networking & TCP/IP for Developers avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.

Dois-je avoir de l'expérience pour commencer Linux Networking & TCP/IP for Developers ?

Aucune expérience préalable n'est requise. Linux Networking & TCP/IP for Developers sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 1 sur 4.

Combien de temps prend la leçon « Gestion des interfaces réseau » ?

La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.

Peux-tu écrire et exécuter du code dans cette leçon Linux Networking & TCP/IP for Developers ?

Oui. Chaque leçon Linux Networking & TCP/IP for Developers inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.

Toutes les leçons de ce cours

  1. Gestion des interfaces réseau
  2. Tables de routage et passerelles
  3. Configuration et résolution DNS
  4. Configurer le pare-feu Linux avec nftables
← Retour à Linux Networking & TCP/IP for Developers