Initial Settings after installing the CentOS 7

1) To change the hostname permanently, edit the following file:

sudo vi /etc/hostname

centos7

Here you can simply put the name of your system (in my case, I have assigned it CentOS-7):

centos7 (1)

After that, edit the hosts file:

sudo vi /etc/hosts

centos7 (2)

Here add the same name, that you have added in the /etc/hostname file, after 127.0.0.1:

centos7 (3)

After reboot, it will display the new hostname.

2) After login to the CentOS7 server(minimal installation), you will notice that the system doesn’t have ifconfig command :

centos7 (4)

Install the net-tools package which will include ifconfig:

sudo yum install net-tools

centos7 (5)

Try the ifconfig command once again:

centos7 (6)

3) Change the default network interface name to “eth0″

CentOS7 has a default nic name as “en016…..”, as we can see in above screenshoot. To change it back to the default network device name like “ethX”, edit the grub file:

sudo vi /etc/default/grub

centos7 (7)

Search for the line “GRUB_CMDLINE_LINUX” and append the following: “net.ifnames=0 biosdevname=0

Will look like this:

GRUB_CMDLINE_LINUX="rd.lvm.lv=rootvg/usrlv rd.lvm.lv=rootvg/swaplv crashkernel=auto 
vconsole.keymap=usrd.lvm.lv=rootvg/rootlv vconsole.font=latarcyrheb-sun16 rhgb 
quiet net.ifnames=0 biosdevname=0"

centos7 (8)

Create a new configuration based on the currently running system using grub2-mkconfig command:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

centos7 (9)

Rename the interface files by renaming the file “/etc/sysconfig/network-scripts/ifcfg-en01…

sudo mv /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eth0

centos7 (10)

Reboot the system:

centos7 (11)

After reboot, check the interface name:

centos7 (12)

4) Configure the static ip on the server:

Edit the interface file under /etc/sysconfig/network-scripts/ directory:

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

centos7 (13)

Here is my ifcfg-eth0 file as a sample, please change it according to your requirement:

DEVICE="eth0"
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.250.50
NETMASK=255.255.255.0
GATEWAY=192.168.250.2
DNS1=192.168.250.2

centos7 (14)

Stop and disable the NetworkManager service, because we don’t need it on the server:

sudo systemctl stop NetworkManager 
sudo systemctl disable NetworkManager

centos7 (15)

Restart the network service(Be careful, if you are connecting remotely, because you will be disconnected after issue this command):

sudo service network restart

centos7 (16)

Check the newly assigned static ip:

centos7 (17)

5) Disable IPv6:

First check that IPv6 is enabled or not:

lsmod | grep -i ipv6

centos7 (18)

Edit the grub file:

sudo vi /etc/default/grub

centos7 (19)

Search for the line “GRUB_CMDLINE_LINUX” and add the following at the beginning: “ipv6.disable=1

Will look like this:

GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=rootvg/usrlv...

centos7 (20)

Create a new configuration based on the currently running system using grub2-mkconfig command:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

centos7 (21)

Reboot the system:

centos7 (22)

Once again, check the IPv6 on the system:

centos7 (23)

6) EPEL repository on Centos 7

To install the EPEL repository, issue the following command:

sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm

centos7 (24)

List your new repos:

sudo yum repolist

centos7 (25)

7) Enable iptables services(instead of firewalld):

When you will try to start/restart the iptables on newly install server, will get this error:

centos7 (26)

To fix this error, install the iptables-services package:

sudo yum install iptables-services

centos7 (27)

Re-run the command to restart the iptables:

sudo service iptables restart

centos7 (28)

Hope this will help you!