How to add/change IP address in Centos7 minimal

How to add/ip address in centos7 minimal after 1st installation

There are many system administrator who faces problem adding ip address in centos7 minimal after 1st installation because in the centos7 some command has been changed & setup command disappear in this version. Here i will discuss about how to setup ip address in centos 7 from command line.

First, type “#nmcli d” command in your terminal for quick list ethernet card installed on your machine:

Type “#nmtui” command in your terminal to open Network manager. After opening Network manager chose “Edit connection” and press Enter (Use TAB button for choosing options).

Manual Installation

If you are familiar with using the vi editor you can also modify the ifcf-eth0 file using vi. To use this option, type the following command in the prompt:

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

You can also use nano as a text editor. If you are newer to Linux this editor has less of a learning curve than vi. Nano will need to be installed using the command: 

yum install nano Once installed, to use nano to edit the file type: nano /etc/sysconfig/network-scripts/ifcfg-enp0s3

Here is an example of the file using 192.168.1.2 as the static IP address.

TYPE=Ethernet

BOOTPROTO=none

DEFROUTE=yes

IPV$_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=enp0s3

UUID=”WHAT EVER IS YOUR COMPUTER’s UUID”

ONBOOT=yes

HWADDR=”WHATEVER IS YOUR COMPUTER’S MAC ADDRESS”

IPADDR=192.168.1.2

PREFIX=24

GATEWAY=192.168.1.1

DNS=192.168.1.1

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

Restarting the networking service

You may have to restart the network adapter or the machine. To restart the network adapter use the following command: service network restart.

Using ifconfig

If you wish to install the common networking tools you can now install the net-tools package using the following command: yum install net-tools

This will allow you to view your network adapters using the terminal command: ifconfig

 

Leave a Reply

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