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 --import http://mirrors.nayatel.com/epel//RPM-GPG-KEY-EPEL-7
sudo rpm -Uvh http://mirrors.nayatel.com/epel/7/x86_64/e/epel-release-7-1.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!

Please Remember me in your prayers!

Enjoy :-)

 

11 responses to “Initial Settings after installing the CentOS 7

  1. Pingback: CentOS 7 系統基本調校 « Jamyy's Weblog

  2. star wars cartel coins generator September 24, 2014 at 4:51 am

    I was suggested this web site by my cousin. I am
    not sure whether this post is written by him as nobody else know such detailed about my difficulty.
    You are amazing! Thanks!

  3. LOAS October 25, 2014 at 12:30 am

    Thanks for a useful writeup.

  4. Pingback: Initial Settings after installing the CentOS 7 | Lazy Geek -:) | The Winding Journal

  5. Paul Kim April 17, 2015 at 6:18 am

    Thank you. It’s very useful doc.

  6. cjbidwellhris April 25, 2015 at 3:50 am

    I have found that after the initial reboot after changing the ifconfig settings that the /etc/sysconfig/network-scripts/ifcfg-eth0 seems to add a ‘0’ at the end of some of the parameter names — gateway0 = 192.168.0.254, ipaddr0 = 192.168.0.1, etc. Has anyone else experienced this?

  7. Pingback: Initial Settings after installing the CentOS 7 | Lazy Geek -:) | The Winding Journal

  8. Pingback: How to change a network interface name on CentOS 7 | dogged work

  9. pedromundo January 21, 2016 at 8:03 pm

    Thanks for this, just started running a box again after the CentOS version change. This was extremely helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: