Friday, February 6, 2015

ifconfig not found,use nmcli d and set the IP Adress on CentOS 7

By default on the core minimal configuration of CentOS Server ifconfig is not present

you have to install net-tools rpm from the dvd under the Packages folder to get ifconfig

use nmcli d to see the available network cards 

from GUI mode(if GUI is available ) use the command

nmtui

to set the ip 

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

 TYPE=Ethernet
 BOOTPROTO=none
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=no
 IPV6INIT=yes
 IPV6_AUTOCONF=yes
 IPV6_DEFROUTE=yes
 IPV6_FAILURE_FATAL=no
 NAME=enp0s17
 UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
 ONBOOT=no
 HWADDR=00:0C:29:A1:B5:D6
 PEERDNS=yes
 PEERROUTES=yes
 IPV6_PEERDNS=yes
 IPV6_PEERROUTES=yes

For DHCP
 Find the below lines in config File.
BOOTPROTO=none
 ONBOOT=no

and replace with

BOOTPROTO=dhcp
 ONBOOT=yesNow Restart network service by typing below command.

systemctl restart network

For Static IP.
 Find the below lines in config File.
BOOTPROTO=none
 ONBOOT=no

and replace with

BOOTPROTO=static
 ONBOOT=yes

And add the below lines at the end of the file.

IPADDR=192.168.28.51
 NETMASK=255.255.255.0
 GATEWAY=192.168.28.50
 DNS1=192.168.28.50

File will look like below after changes.
TYPE=Ethernet
 BOOTPROTO=static
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=no
 IPV6INIT=yes
 IPV6_AUTOCONF=yes
 IPV6_DEFROUTE=yes
 IPV6_FAILURE_FATAL=no
 NAME=enp0s17
 UUID=f0c5b37d-299a-43cb-b74b-618bb252d129
 ONBOOT=yes
 HWADDR=00:0C:29:B1:C5:BB
 IPV6_PEERDNS=yes
 IPV6_PEERROUTES=yes
 IPADDR=192.168.28.51
 NETMASK=255.255.255.0
 GATEWAY=192.168.28.50
 DNS1=192.168.28.50

Now Restart network service by typing below command.
systemctl restart network

you can use /etc/sysconfig/network file for hostname and DNS .
HOSTNAME=server1.sourav.com
 DNS1=192.168.0.50
 DNS2=4.2.2.2
 SEARCH=sourav.com

No comments:

Post a Comment