Configure Static and Dynamic Network Settings on a CentOS 6.7 VM
This guide walks you through logging into a CentOS 6.7 virtual machine, editing the network interface file to set static IP parameters or enable DHCP, disabling the firewall, restarting the network service, and verifying connectivity with ifconfig and ping commands.
Static Network Configuration
1. Log into the virtual machine with your credentials.
2. Open the network interface configuration file: vi /etc/sysconfig/network-scripts/ifcfg-eth0 3. Modify the file so that ONBOOT=yes and BOOTPROTO=static, then add the required network parameters:
IPADDR=your_ip_address
NETMASK=your_subnet_mask
GATEWAY=your_gateway
DNS1=primary_dns
DNS2=secondary_dns
4. Save and exit the editor ( :wq!).
5. Verify the changes: cat /etc/sysconfig/network-scripts/ifcfg-eth0 6. Stop the firewall: service ip6tables stop 7. Restart the network service: service network restart 8. Check the assigned IP address: ifconfig 9. Test connectivity by pinging an external site:
ping www.baidu.comDynamic Network Configuration (DHCP)
1. Edit the same interface file: vi /etc/sysconfig/network-scripts/ifcfg-eth0 2. Ensure ONBOOT=yes is set and leave other parameters at their defaults to use DHCP.
3. Save and exit, then restart the network service: service network restart 4. Verify the dynamically assigned IP address:
ifconfigNote: DHCP assigns IPs dynamically, which may not be suitable for environments like Hadoop clusters that require stable static addresses.
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.
