Operations 4 min read

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.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Configure Static and Dynamic Network Settings on a CentOS 6.7 VM

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.com

Dynamic 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:

ifconfig

Note: DHCP assigns IPs dynamically, which may not be suitable for environments like Hadoop clusters that require stable static addresses.

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.

LinuxCentOSStatic IP
Python Crawling & Data Mining
Written by

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!

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.