How to configure network connection on CentOS 7 Server

Hello everyone, today we will learn about CentOS 7 Server which is no GUI installed. I use CentOS for several purposes such as web server, database server, multimedia server, file server and many more. On this short tutorial, we will show you how to configure network connection on CentOS 7 Server. There is no GUI access to the network connection, so we need to configure it via Terminal console. 

We will use a tool called nmtui (Network Manager Text User Interface) which is a usable network connection manager for CentOS. This tool is helpful to configure network on CentOS and its installed by default during CentOS installation. OK, lets get started. 

Steps to configure network connection on CentOS 7

Log in to CentOS console as root and run the nmtui command to start 

nmtui

You will see nmtui interface as follow

We will start from here. 

A. Edit a Connection

This menu is used to configure the connection. We can add, edit or delete connection with this menu. Move your cursor to “Edit a connection” and then hit enter. 

You should see your current network connection/device listed here. To create a new connection click Add. As you can see, currently I have enp0s3 profile connection listed. I would like to edit it. Please note that this could be different with your settings. We will change the how the IP address delivered to my CentOS. 

Configure Static IP address

On the edit connection menu, enter the IPv4 address, gateway, DNS server with your own. By doing this, CentOS will get a static IP address you specified. For example:

configure network connection on centos 7

Configure Automatic IP addressing via DHCP

If your network has a DHCP Server you can set the IP address to automatic. By doing this, CentOS will get IP address from the DHCP server. See example below

Hit OK when ready and it will returned to the previous page. 

B. Activate a Connection

Once we have edit and configure the connection. We can activate the connection. From main nmtui menu, hit Activate a connection. 

Hit Activate to enable the connection. At this point, your network connection should works properly. You can try to ping and check the IP address. 

ip addr

Output:

[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:59:54:03 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.9/32 brd 192.168.1.9 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::d8a1:74a4:d19f:4dbe/64 scope link 
       valid_lft forever preferred_lft forever

Ok, now our network is well configured. Thanks for reading this How to configure network connection on CentOS 7. Cheers.

Be the first to comment

Leave a Reply