Operations 3 min read

Configure Linux Network Interfaces and Enable Dynamic IP – Step-by-Step Guide

This guide explains how to locate Linux network‑script files, edit the interface configuration to use DHCP or a static address, and restart the network service, with example commands and screenshots illustrating virtual machine network settings and dynamic IP acquisition.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Configure Linux Network Interfaces and Enable Dynamic IP – Step-by-Step Guide

Locate Network‑Script Files

On a CentOS/RHEL system the network interface definitions reside in /etc/sysconfig/network-scripts/. You can list the directory and view the existing ifcfg-* files with:

# ls /etc/sysconfig/network-scripts/
# ls -l /etc/sysconfig/network-scripts/ifcfg-*

Typical output shows files such as ifcfg-ens33 (the primary Ethernet interface) and ifcfg-lo (the loopback).

Edit the Interface Configuration

Open the relevant ifcfg-ens33 (or the appropriate interface name) with a text editor and adjust the parameters. To enable a dynamic IP address, set BOOTPROTO=dhcp and ensure ONBOOT=yes. For a static address, specify IPADDR, NETMASK, GATEWAY, etc.

Example of a DHCP‑enabled file:

DEVICE=ens33
TYPE=Ethernet
BOOTPROTO=dhcp
ONBOOT=yes

After saving, restart the network service:

# systemctl restart network   # or: # service network restart

Virtual Machine Network Settings

Ensure the VM’s virtual network adapter is attached to a bridged or NAT network so that the guest can obtain an address from the host or external DHCP server. The following screenshots illustrate the VM network configuration and the edited ifcfg-ens33 file.

Dynamic IP Illustration

After restarting, the interface will obtain an IP address from the DHCP server, which can be verified with ip addr show or ifconfig.

Source: https://www.cnblogs.com/btcm409181423/p/17977163
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

operationsLinuxNetwork ConfigurationCentOSDynamic IPSysconfig
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.