gb
  English
Phone:  +1 (217) 636-4164
Skype:  onegbits
  1. Home
  2. Blog
  3. Configure Static IP in CentOS 7

Configure Static IP in CentOS 7

Configure Static IP in CentOS 7

06

Feb, 18

635

In CentOS 7 and other Linux distributions, default protocol for network configuration is DHCP. If you need to set static IP on your server, you must configure it. In this tutorial we will show you how to configure static IP in CentOS 7 furthermore, you will get familiar with nmtui command.

Configure Static IP in CentOS 7

Step 1: First, verify your network adapter status using the following command:

systemctl status NetworkManager.service

This command will display you weather your network adapter in on or off.

Step 2: Issue the following command to display network interfaces’ names:

nmcli dev status

We need these name in next steps.

1_8

In previous picture, you see that our interface name is eno16777984.

There are two methods to configure static IP on CentOS 7.

First method: Using terminal commands.

Second method: Using Network Manger tool.

Configure Static IP on CentOS 7 Using Terminal Commands

Change directory to /etc/sysconfig/network-scripts.

cd /etc/sysconfig/network-scripts

Issue ls command to find your interface name. Interface name will start with ifcfg- prefix. For example, our interface name is ifcfg-eno16777984 here.

Open interface interface config file using the following command:

nano ifcfg-eno16777728

You will see the following content in this file. Enter your IP detail and save and exit.

TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="yes"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777728"
UUID="6515e1f5ff46-410f97bc47d35c6d7bf8"
ONBOOT="yes"
IPADDR0="192.168.1.10"
PREFIX0="24"
GATEWAY0="192.168.1.1"
DNS1=8.8.8.8
DNS2=8.8.4.4
HWADDR=00:50:56:AD:6D:41
DOMAIN=rheltest.lan
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

Now restart your network service using the following command:

systemctl restart network.service

To verify your configuration, you can use the following command.

ip add

That is all. You can use newly configured IP on your server.

Configure Static IP on CentOS 7 Using Network Manager

You can use Network Manager package to simplify network configuration tasks. This package is installed on CentOS 7 by default. If not, you can install it using the following command:

yum install NetworkManager-tui

To edit your interface, use the following command:

nmtui edit eno16777728

You can configure your IP detail similar to the below picture:

2_7

Edit your IP detail and press OK at the end. Then restart your network service using the following command:

systemctl restart network.service

Congratulations! You have learned  how to Configure Static IP in CentOS 7 using two methods.

If you are facing any problem with the installation, fell free to comment here. We will help you to solve the issue.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave A Comment
We are with you

24 X 7 X 365

+1 (217) 636-4164

©2017 1Gbits. All rights reserved