Changing the Static IP Address in CentOS 7 Print

  • IP, network, centos 7
  • 0

Sure! Here are simple step-by-step instructions for changing the static IP address in CentOS 7:

 

Changing the Static IP Address in CentOS 7

 

  1. Access the Terminal: Open the Terminal on your CentOS 7 system. You can do this by clicking on the "Activities" button (top-left corner), searching for "Terminal," and then clicking on the Terminal application.

  2. Switch to Superuser (root): To make changes to the network settings, you need administrative privileges. Type the following command and press Enter:

    sudo su
    

    You will be prompted to enter your user password. Once you provide the password, you will switch to the superuser (root) account.

  3. Locate the Network Configuration File: In CentOS 7, the network configuration is stored in the file /etc/sysconfig/network-scripts/ifcfg-eth0 (assuming your interface is named "eth0"). To check the current configuration, use the following command:

    cat /etc/sysconfig/network-scripts/ifcfg-eth0

    (Replace "eth0" with the appropriate interface name if needed.)

  4. Backup the Current Configuration (Optional): Before making any changes, it's a good idea to create a backup of the current configuration file. You can use the cp command to make a copy:

    cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.backup
  5. Edit the Network Configuration File: Use a text editor (like Nano or Vim) to modify the network configuration file. Here, we'll use Nano:

     
    nano /etc/sysconfig/network-scripts/ifcfg-eth0
  6. Update the IP Address: In the editor, locate the line that starts with IPADDR= and replace the existing IP address with the new static IP address you want to assign to your CentOS 7 system. For example:

    IPADDR=192.168.1.100
  7. Update the Network Mask: If necessary, locate the line that starts with NETMASK= and update the network mask. The default is usually 255.255.255.0.

  8. Update the Default Gateway (Optional): If you need to change the default gateway, locate the line that starts with GATEWAY= and update it with the appropriate gateway IP address.

  9. Update the DNS Servers (Optional): To change the DNS servers, locate the line that starts with DNS1= (primary DNS) and DNS2= (secondary DNS) and update them with the desired DNS server addresses.

  10. Save and Exit the Editor: After making the changes, press Ctrl + O to save the file, and then Ctrl + X to exit Nano.

  11. Restart the Network Service: To apply the changes, you need to restart the network service. Use the following command:

    systemctl restart network
  12. Verify the Changes: Check if the new static IP address has been applied correctly by using the ip addr command:

    ip addr show eth0

    (Again, replace "eth0" with your interface name if it's different.)

  13. Test Network Connectivity: Finally, test your network connectivity to ensure everything is working as expected. You can try to ping a website or another device on your network.

That's it! You have successfully changed the static IP address in CentOS 7. Your system should now be using the new IP address you specified in the network configuration file.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution