Change Ip Address On Centos 7

admin13 April 2024Last Update :

Understanding IP Configuration in CentOS 7

CentOS 7, a popular server operating system, uses a set of configuration files and command-line tools to manage network settings. Understanding how these configurations work is crucial for any system administrator or user looking to change their IP address.

Network Management Frameworks

CentOS 7 typically employs two main frameworks for network management: network scripts and NetworkManager. Network scripts are traditional ifcfg files located in


, while NetworkManager is a dynamic daemon that manages network settings via command-line interface (nmcli) or a graphical interface (nmtui).

Static vs. Dynamic IP Addressing

Before changing an IP address, it’s important to understand the difference between static and dynamic addressing. Static IP addresses are manually assigned and do not change unless reconfigured. In contrast, dynamic IP addresses are assigned by a DHCP server and can change upon lease renewal or reconnection.

Changing IP Address Using Network Scripts

To manually configure a static IP address on CentOS 7 using network scripts, you’ll need to edit the appropriate configuration file for your network interface.

Identifying Your Network Interface

Firstly, identify the network interface you wish to configure with the following command:

ip addr show

This will list all available network interfaces along with their current IP addresses.

Editing Network Configuration Files

Once you’ve identified the correct interface (e.g., eno16777736), proceed to edit its configuration file found at


You can use a text editor like vi or nano to make changes to this file.

  • Open the file with a text editor, such as vi:
    vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
  • Locate and modify the following lines to match your desired network configuration:
  • Save the file and exit the text editor.

Applying Network Configuration Changes

After saving the configuration file, restart the network service to apply the changes:

systemctl restart network

Alternatively, you can bring down and up the interface individually:

ifdown eno16777736 && ifup eno16777736

Changing IP Address Using NetworkManager

For those who prefer a more dynamic approach, NetworkManager provides a powerful toolset for managing network configurations.

Using nmcli Tool

The nmcli tool allows you to change the IP address from the command line quickly.

  • To view current connections, use:
    nmcli con show
  • To modify an existing connection, use:
    nmcli con mod eno16777736 ipv4.addresses ipv4.gateway ipv4.dns "," ipv4.method manual
  • Apply the changes by reloading the connection:
    nmcli con up eno16777736

Using nmtui Tool

For those who prefer a graphical interface, nmtui offers a simple text user interface to manage network settings.

  • Launch nmtui:
  • Navigate to ‘Edit a connection’ and select the relevant interface.
  • Enter the desired IP address, gateway, DNS, and other settings.
  • Select ‘OK’ and then ‘Back’ to exit, and finally, ‘Quit’.
  • Restart the NetworkManager service to apply changes:
    systemctl restart NetworkManager

Advanced IP Management

Beyond basic IP configuration, CentOS 7 also supports advanced networking features such as bonding, bridging, and teaming.

Creating Network Bonds and Bridges

Network bonds combine multiple network interfaces into a single logical interface for redundancy or increased throughput, while bridges allow virtual machines to share a physical network interface.

Implementing Network Teaming

Teaming is another method of linking multiple network interfaces to form a single logical interface, offering similar benefits to bonding but with additional features and flexibility.

Troubleshooting Network Issues

After changing an IP address, you may encounter connectivity issues. Common troubleshooting steps include verifying configuration files, checking cable connections, and testing network services.

Common Commands for Troubleshooting

Useful commands for diagnosing network problems include ping, traceroute, netstat, and ss. These tools can help pinpoint where a connection might be failing.

Frequently Asked Questions

How do I find my current IP address in CentOS 7?

Use the

ip addr show

command to display all network interfaces and their associated IP addresses.

Can I set multiple IP addresses on a single interface in CentOS 7?

Yes, you can assign multiple IP addresses to a single interface by creating alias interfaces or using the nmcli tool to add secondary IP addresses.

What should I do if I cannot connect to the internet after changing my IP?

Check your configuration for typos, ensure your gateway and DNS settings are correct, and verify that your network cables are securely connected. Restarting the network service or rebooting the system can also resolve some issues.

Is it possible to change the IP address without downtime?

Yes, using the nmcli tool or ifup/ifdown commands allows you to change the IP address without requiring a full system restart, minimizing downtime.

How do I configure my CentOS 7 machine to obtain an IP address automatically?

Set the BOOTPROTO directive to dhcp in the network script file or use nmcli to set the connection’s ipv4.method to auto.


Leave a Comment

Your email address will not be published. Required fields are marked *

Comments Rules :

Breaking News