Skip to main content

Set static IP on CentOS

Step 1: Check the current state

After editing the NIC, the NIC IP is 132.0.0.70.

NIC information for a CentOS VM on FPT Cloud Portal

Open Console and check the current IP address with:

ip a

Output of ip a command in the CentOS VM Console

Step 2: Open the network interface configuration file

Open the file ifcfg-eth0 with:

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

File ifcfg-eth0 open in the vi editor

Step 3: Edit the configuration values

  1. Press i to enter Insert mode.
  2. Update the IP address, gateway, and DNS to match the new configuration.

Editing IP parameters in ifcfg-eth0

  1. Press Esc, type :wq, and press Enter to save and exit.

Saving the configuration file with  in vi

Step 4: Restart the network service

Run the following command to apply the changes:

service network restart

Output of network service restart on CentOS

Step 5: Verify and test connectivity

Run ip a again to confirm the IP address has been updated, then run a ping test to verify connectivity.

Verification of new IP settings and ping test on CentOS