Linux serverNETWORK ADMINISTRATIONS

How to configure a static IP address in CentOS | on CentOS 7 / RHEL 7 | IP Address in CentOS

To configure a static IP address in CentOS, follow these steps:
Find the name of your network interface. You can do this by running the following command:
ip a
This will list all of the network interfaces on your system. The name of your network interface will be something like eth0 or ens33.

Edit the network interface configuration file. The network interface configuration file is located at /etc/sysconfig/network-scripts/ifcfg-eth0 (or whatever the name of your network interface is). You can edit this file using any text editor, such as nano or vim.

Add the following lines to the configuration file:

BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
BOOTPROTO=none tells the network interface to use a static IP address instead of obtaining one from a DHCP server.
ONBOOT=yes tells the network interface to start up when the system boots.
IPADDR is the static IP address that you want to assign to the network interface.
NETMASK is the netmask for the network that the computer is on.
GATEWAY is the IP address of the default gateway for the network.
DNS1 and DNS2 are the IP addresses of the DNS servers that the computer will use to resolve domain names.
Save the configuration file.

Restart the network interface. You can do this by running the following command:

service network restart
Your computer will now be using the static IP address that you specified.

Note: If you are using NetworkManager to manage your network connections, you can configure a static IP address using the NetworkManager GUI. To do this, follow these steps:

Open the NetworkManager GUI. You can do this by clicking on the network icon in the system tray and selecting Network.
Select the network interface that you want to configure.
Click on the Edit button.
Click on the IPv4 tab.
Select the Manual method.
Enter the static IP address, netmask, gateway, and DNS server addresses in the appropriate fields.
Click on the Save button.
Your computer will now be using the static IP address that you specified.

source

centos 7