How to Change Your IP Address in Centos 7

by | Feb 9, 2023 | Uncategorized

DHCP network setting is used by default in Linux installations. A client/server protocol called DHCP assigns IP addresses to the host on demand. Additionally, it contains details about the IP, including its subnet mask and default gateway. It consequently receives an IP address from a router on your network automatically. Although this dynamic protocol has several benefits, some operations need a static IP address. A File/Web server is a nice illustration. In this post, we’ll demonstrate how to modify the IP address of a CentOs 7 Linux host or how to configure static IP.

We are using the IPV4 address information as an example.

IP Address: 147.124.***.***

Gateway: 147.***.208.*

Netmask: 255.255.***.***

DNS: 8.8.8.8/8.8.4.4

Using the ifcfg Files, change the IP address

The software terminal for specific network devices is managed via the ifcfg files. These files are used by the system at boot-up to choose which terminal to launch and how to configure it. On CentOS 7, navigate to the specified ifcfg file and make the necessary changes.

  • Let’s first use the provided command to determine the network interface name.
# ifconfig -a
  • After that, use the provided command to open the network interface configuration file, which will do so with the default data.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
  • Edit the file containing the static IP information and save it to change the IP to static.
  • Now use the provided command to restart the network manager service.
# systemctl restart network
  • You can see that the server’s IP has changed to the IP in the example after the restart.

Using NMTUI, change the IP

A curses-based TUI programme called Network Manager Text User Interface is used to communicate with NetworkManager. Unless it was supplied as the first argument, the user is requested to select the activity to carry out when nmtui starts. The NMTUI tool is pre-installed on 99RDP Linux VPS. Run it initially using the terminal’s # nmtui command.

  • Choose Edit a connection, then pick the eth0 network device.
  • Enter and save the static IP information.
  • Restart the computer after quitting the Network Manager.

Conclusion

These two options are your final two choices for changing the IP address of your CentOS 7 server. Other Linux distributions have a similar set of options.

Read Our Next Articles On Windows Server 2019, Enable Ping