My linux world » Centos configuration

Centos configuration


Contents

Static ip and DNS

Configuration

Edit file /etc/sysconfig/network-scripts/ifcfg-ens33:

DEVICE=ens33
BOOTPROTO=none
BROADCAST=192.168.0.255
HWADDR=00:0A:BC:DE:FF:1E
IPADDR=192.168.0.16
NETMASK=255.255.255.0
ONBOOT=yes
GATEWAY=192.168.0.1
TYPE=Ethernet
IPV6INIT=no
DNS1=192.168.0.2
DNS2=192.168.0.3
DOMAIN=my-domain.local

In the file /etc/resolv.conf you will see these lines:

search my-domain.local
nameserver 192.168.0.2
nameserver 192.168.0.3

Troubleshooting

My network interface ens33 is not in the list of the ifconfig command

  1. #!/bin/bash
  2.  
  3. # get current device (i.e. ens33)
  4. currentDevice=`nmcli d | grep connected | awk '{split($1,a,"\t"); print a[1]}'`
  5.  
  6. echo "start manually device $currentDevice"
  7. ifup $currentDevice
  8.  
  9. echo "edit /etc/sysconfig/network-scripts/ifcfg-$currentDevice and set ONBOOT=yes"
  10. sed -i "s/^\(ONBOOT=\).*$/\1yes/g" /etc/sysconfig/network-scripts/ifcfg-$currentDevice
  11.  

“Device ens33 does not seem to be present” (after cloning the server)

Edit /etc/udev/rules.d/70-persistent-net.rules
And update the MAC adress:

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0A:BC:DE:FF:1E", ATTR{type}=="1", KERNEL=="eth*", NAME="ens33"

show gateway IP address

ip route show

Use external repositories

  1. #!/bin/bash
  2.  
  3. echo "get release rpm from fedora"
  4. yum -y install epel-release
  5.  
  6. #echo "enable Red Hat Software Collections (SCL) repository"
  7. #yum -y install centos-release-scl
  8.  
  9. echo "clean all and update"
  10. yum clean all
  11. yum -y install deltarpm
  12. yum -y update
  13.  

Firewall

  1. #!/bin/bash
  2.  
  3. echo "install firewalld"
  4. yum -y install firewalld
  5.  
  6. echo "activate firewalld at startup"
  7. systemctl enable firewalld.service
  8.  
  9. echo "start service"
  10. systemctl start firewalld.service
  11.  

NTP server (date & time)

  1. #!/bin/bash
  2.  
  3. echo "install ntp"
  4. yum -y install ntp
  5.  
  6. echo "activate ntp on boot"
  7. systemctl enable ntpd.service
  8.  
  9. echo "start ntp service"
  10. systemctl start ntpd.service
  11.  

SELinux

Edit the file : /etc/selinux/config and set SELINUX to disabled like this:

  1. #!/bin/bash
  2.  
  3. sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
  4.  
  5. echo "disable selinux temporary (without reboot)"
  6. setenforce 0

Note: changes will take effect after reboot.

Usefull commands

  1. #!/bin/bash
  2.  
  3. echo "install ifconfig"
  4. yum -y install net-tools
  5.  
  6. echo "install locate"
  7. yum -y install mlocate
  8. updatedb
  9.  
  10. echo "install wget"
  11. yum -y install wget
  12.  
  13. echo "install dos2unix"
  14. yum -y install dos2unix
  15.  
  16. echo "install telnet client"
  17. yum -y install telnet
  18.  
  19. echo "install zip tools"
  20. yum -y install zip unzip
  21.  

Autoupdate

  1. #!/bin/bash
  2.  
  3. ## Package Manager
  4. echo "install yum-cron"
  5. yum -y install yum-cron
  6.  
  7. echo "activate yum-cron at startup"
  8. systemctl enable yum-cron.service
  9.  
  10. echo "start service"
  11. systemctl start yum-cron.service
  12.  

Change hostname

Activate nrpe (for nagios)

  1. #!/bin/bash
  2.  
  3. echo "install nrpe"
  4. yum -y install nrpe nagios-plugins-all
  5.  
  6. echo "start nrpe on boot"
  7. systemctl enable nrpe.service
  8.  
  9. echo "add service nrpe (port 5666) to firewall"
  10. firewall-cmd --permanent --zone=public --add-port=5666/tcp
  11.  
  12. echo "sudoers configuration (deal with issue 'NRPE: Unable to read output')"
  13. chmod 755 /etc/sudoers
  14. sed -i "s/^\(Defaults\s*requiretty\)/#\1/" /etc/sudoers
  15. chmod 0440 /etc/sudoers
  16.  
  17. echo "allow every one to connect to nrpe"
  18. sed -i "s/^\(allowed_hosts\)/#\1/" /etc/nagios/nrpe.cfg
  19.  
  20. echo "start nrpe"
  21. systemctl start nrpe.service
  22.  

Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.