This recipe shows you how to configure a static IP address. Unless you configured a static address during installation, CentOS uses the Dynamic Host Configuration Protocol (DHCP) to obtain an IP address to communicate across the network. Using a dynamically assigned address is fine for most desktop and laptop systems, but those that host e-mail servers, file sharing and print services, and web servers should have an address that doesn't change. The static address provides a stable, known location on the network where users can access a system's services.
This recipe requires a CentOS system with a working network connection and administrative privileges provided by logging in with the root
account. It assumes that your primary Ethernet device is named enp0s3
and is currently configured with DHCP. If your device is named differently, substitute its name appropriately in the following commands.