New CentOS 7 Server Setup Commands
From Labrats.us
Jump to navigationJump to searchInstall From Image, with 'minimal install' option
Post install configuration
Remove Network Manager software
# /bin/systemctl disable NetworkManager # /bin/systemctl disable NetworkManager-dispatcher # yum erase NetworkManager-tui NetworkManager-glib NetworkManager
Configure Network
Run the commands below to set up a static ip address (192.168.1.221) and hostname (test-centos-1).
# export remote_hostname=guest1 # export remote_ip=192.168.1.221 # export remote_gateway=192.168.1.1 # hostnamectl set-hostname $remote_hostname # sed -i.bak "s/.*BOOTPROTO=.*/BOOTPROTO=none/g" /etc/sysconfig/network-scripts/ifcfg-eth0 # cat << EOF >> /etc/sysconfig/network-scripts/ifcfg-eth0 IPADDR0=$remote_ip PREFIX0=24 GATEWAY0=$remote_gateway DNS1="216.136.95.2" DNS2="64.132.94.250" NM_CONTROLLED="no" EOF # systemctl restart network # systemctl enable network.service # systemctl enable sshd # systemctl start sshd # echo "checking connectivity" # ping www.google.com
Disable selinux
# setenforce 0 # sed -i.bak "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
Remove Postfix, and add needed packages.
# yum -y erase postfix # yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ perl-DBD-SQLite sendmail sendmail-cf sssd tcp_wrappers tcpdump telnet tftp \ tog-pegasus traceroute vim-enhanced wget oddjob-mkhomedir net-tools yum-cron \ bind-utils
Alternately, you can leave Postfix and just install needed packages.
# yum -y install finger nc net-snmp net-snmp-perl net-snmp-utils ntp perl-Date-Manip \ perl-DBD-SQLite sssd tcp_wrappers tcpdump telnet tftp tog-pegasus traceroute \ vim-enhanced wget oddjob-mkhomedir net-tools yum-cron bind-utils
Fix Time Zone
# rm -f /etc/localtime # ln -s /usr/share/zoneinfo/MST7MDT /etc/localtime
Turn off rp_filter
# echo "net.ipv4.conf.default.rp_filter = 0" > /etc/sysctl.d/rpfilter.conf
Update required Packages
# yum update kernel bash nss nspr ntp glibc cvs
Reboot Server to apply new kernel
# shutdown -r now
Remove old kernel so system scans cleanly and update kernel tools
# rpm -qa | grep kernel # yum -y erase kernel-<old kernel version> # yum -y update kernel-tools kernel-tools-libs
Install VM Tools
If this is a virtual machine, install the open vm tools.
# yum -y install open-vm-tools