Advance

Set static IP on CentOS 7

Set static IP on CentOS 7
1
(1)

Previously, you learned how to set IP static on Ubuntu, in this article you will review how to set static IP on CentOS 7. By default on CentOS 7 Linux and other distributions, network settings are set to automatically receive IP from DHCP. But in general, you need to make adjustments if you are setting up a server or need fixed IP in certain situations. In this tutorial, in addition to setting the static IP on CentOS 7, we will learn how the nmtui command works.

Buy Cheap Linux Server

How to set static IP on CentOS 7

1- First, by entering the following command, we check the status of the network card.

After entering the following command, you will be informed whether your network card is active or inactive.

systemctl status NetworkManager.service

2- Enter the following command to display the name of your interfaces.

The interface name is important in subsequent commands in setting static IP.

nmcli dev status

The photo above shows that our interface name is eno16777728.

nmcli show interface on centos 7

Two ways to set up static IP on CentOS 7.

1- Setting static IP by terminal environment commands.

2- Setting static IP by Network Manager.

Recommended Article: Set static IP on CentOS 7

Setting static IP on CentOS 7 by terminal environment commands

1- First, go to /etc/sysconfig/network-scripts path.

cd /etc/sysconfig/network-scripts

2- Enter the ls command to find the name of your interface file.

Ifcfg will be added at the beginning of the interface name. For example, our interface file is in ifcfg-eno16777728.

3- Open the interface settings file with the Vi editor.

vi ifcfg-eno16777728

4- Press the i button and copy the following phrase into it.

Enter your settings in the IPADDR and. Sections.

TYPE="Ethernet"  BOOTPROTO="static"  DEFROUTE="yes"  IPV4_FAILURE_FATAL="yes"  IPV6INIT="yes"  IPV6_AUTOCONF="yes"  IPV6_DEFROUTE="yes"  IPV6_FAILURE_FATAL="no"  NAME="eno16777728"  UUID="6515e1f5-ff46-410f-97bc-47d35c6d7bf8"  ONBOOT="yes"  IPADDR="192.168.1.10"  PREFIX="24"  GATEWAY="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

5- Save the file after entering and setting the desired IP.

To save the file in Vi, first enter the Esc key and enter the phrase :wq and press Enter.

6- After applying the above steps, restart your network service.

systemctl restart network.service

7- By entering the following command, you will see the settings that you have made.

ip a

At this point, your settings are applied and you can use your Linux operating system network.

 

Setting the static IP on CentOS 7 by Network Manager

You can set up your network faster by installing the Network Manager package on With CentOS 7. Of course, this package is available by default in CentOS 7, and if not, install it.

1- You can install Network Manager with the following command.

yum install NetworkManager-tui

2- Go to your interface editing environment with the following command.

nmtui edit eno16777728

3- In this section, as shown below, you can make the desired settings.

It is mandatory to fill the red arrows sections.

Network Manager on Centos 7

4- After entering the desired settings, enter the OK option at the end.

5- Finally, restart your network service.

systemctl restart network.service    

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day