How to Configure Network Settings in CentOS 7

1 – FIND YOUR NETWORK ADAPTER

Once logged in, you’ll want to enable and configure your network adapter.  First, you’ll need to get the name of your network adapter(s) by running the following command:

nmcli d

Below you’ll see my results of running this command.  My results show I have an Ethernet adaptor called ens160 and it’s currently disabled.  Please take note of the name of your network adapter, which may be different.

"nmcli d" Results

2 – CONFIGURE NETWORK ADAPTOR

Once you have the name of your network adapter, you’ll want to enable it and configure it.  We will configure it using the vi text editor.  If you’re not familiar with vi, take a look at:

vi cheat sheet

Use the following command to use vi to configure your network settings.  Note: replace ens160 with the name of your network adapter you noted above)

vi /etc/sysconfig/network-scripts/ifcfg-ens160

The content will look something like this:

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=ens160
UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
DEVICE=ens160
ONBOOT=no

To Configure a DHCP IP

Modify the following lines:

BOOTPROTO=dhcp
ONBOOT=yes

To Configure a Static IP

Modify the following line:

BOOTPROTO=static

Add the following lines and replace them with the static IP settings you need.  Note: DOMAIN is the default DNS Search domain and it’s optional to add that line.

IPADDR=192.168.2.11
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
DNS1=8.8.8.8
DNS2=8.8.4.4
DOMAIN=sigkillit.com

3 – CONFIGURE HOST NAME (Optional)

Optionally, you can use vi to configure the host name and default search domain by running:

vi /etc/hostname

Modify the following line:

HOSTNAME=server.sigkillit.com

4 – RESTART NETWORK SERVICE

To apply your new network settings run the following command to restart the network service

systemctl restart network

 

1 pings

  1. […] ← Previous Next → […]

Comments have been disabled.