STATIC IP CONFIG CENTOS 7

CONFIGURING STATIC IP ADDRESS ON CENTOS 7

Configuring the network and setting up servers into the network is the primary administration task of any System Administrators.

In some cases, It can be automated using DHCP (Dynamic Host Configuration Protocol) Which will automatically assign IP Address to the servers/Desktops.

But In larger Infrastructured companies, In order to avoid network issues, We have to configure static IP Address.

Configuration

Here is some information we will be using in this tutorial:

IPADDRESS: 192.168.10.5

NETMASK : 255.255.255.0

GATEWAY: 192.168.10.1

DNS SERVER 1: 4.2.2.2

DNS SERVER 2: 8.8.8.8

DOMAIN NAME: linuxcloudops.com

To find the available network interfaces on the server, You can use any one of the commands:

#ip a [or]

#ifconfig -a

The output may look like below.

We can see that We have one network interface name eth0.

If you wish to change the IP Address of this network interface, We have to edit the network interface file.

Configure Static IP Address

Method 1

The network interface file will be under /etc/sysconfig/network-scripts/ directory.For example, We can use device name as eth0

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

Open this file and update this interface file as per the requirement, save and close the file.

Method 2

You can also use nmtui a text-based user interface which is used to configure network interfaces.

To use this command, We need to install NetworkManager-tui if not already installed, Like below:

#yum install NetworkManager-tui

Once installed, Just enter nmtui in the terminal and Enter

#nmtui

You will see the following screen.

Choose Edit a connection and press Enter. You will see the below screen.Choose Edit and Press Enter

Set the IP Address and all the required information and enter OK.

Restart the Network Service

We need to restart the network service to have changes take effect.

#systemctl restart network

Verify IP Address

If you wish to verify the IP Address you have set, Use the below command to check:

#ifconfig -a

Verify DNS Entries

To check the DNS entries:

#cat /etc/resolv.conf

You will see something like this:

If you wish to change the name servers, You can edit /etc/resolv.conf file.

That’s All.Thanks for reading this tutorial.Hope It helped you to configure IP Address in your Infrastructure successfully.