Step-by-Step Guide to Configuring a Static Network on CentOS 7.4 VM
This tutorial walks you through logging into a CentOS 7.4 virtual machine, editing the ifcfg‑ens160 file to set a static IP, restarting the network service, and verifying connectivity, helping you avoid common pitfalls when configuring VM networking on newer CentOS releases.
Overview
The author previously shared a CentOS 6.7 network configuration tutorial and, after encountering differences while configuring CentOS 7.4, compiled this guide to help readers set up a static network on a CentOS 7.4 virtual machine.
Static Network Configuration Steps
Log into the VM, navigate to /etc/sysconfig/network-scripts/ and list the files. In CentOS 7.4 the interface configuration file is ifcfg-ens160 , unlike ifcfg-eth0 in CentOS 6.7.
Edit ifcfg-ens160 with vi or vim . The original file contains many entries; you only need to modify two fields and add your network details.
Set ONBOOT to yes and BOOTPROTO to static , then add your IP address, gateway, netmask, DNS1 and DNS2.
Save and exit the editor with :wq! .
Optionally verify the file using cat /etc/sysconfig/network-scripts/ifcfg-ens160 .
Restart the network service: service network restart . A green “ok” indicates success; a red “Failed” suggests configuration errors such as an unavailable IP or unchanged ONBOOT/BOOTPROTO.
Test connectivity with ping baidu.com . Use Ctrl+C to stop the test.
Check the assigned address with ip addr . Note that ipconfig is not available on CentOS.
After completing these steps the virtual machine should be able to access the Internet successfully.
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.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
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.
