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.
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=yesAfter saving, restart the network service:
# systemctl restart network # or: # service network restartVirtual 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
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
