centos6
作用:配置ip、yum源、ntp、关闭selinux、iptables
#!/bin/bash # configure network cat >/etc/sysconfig/network-scripts/ifcfg-eth0<<EOF DEVICE=eth0 NAME="eth0" TYPE=Ethernet ONBOOT=yes BOOTPROTO=static IPADDR=192.168.126.10 PREFIX=24 GATEWAY=192.168.126.2 DNS1=114.114.114.114 EOF # configure yum [ -e /yum ]|| mkdir /yum [ -e /dev/cdrom ]&& mount /dev/cdrom /yum echo "/dev/cdrom /yum iso9660 defaults 0 0" >>/etc/fstab mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/Cen* /etc/yum.repos.d/bak/ cat > /etc/yum.repos.d/local.repo <<EOF [local] name=local baseurl=file:///yum enabled=1 gpgcheck=0 EOF yum clean all yum makecache yum -y install lsof wget sysstat vim lftp man ntp xorg-x11-xauth # configure ssh sed -i 's/^GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config sed -i '/UseDNS/c\UseDNS no' /etc/ssh/sshd_config # configure iptables selinux sed -i '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config chkconfig iptables off chkconfig ip6tables off # configure ntp sed -i 's/^server/#server/' /etc/ntp.conf echo "server time1.aliyun.com iburst" >> /etc/ntp.conf echo "server time2.aliyun.com iburst" >> /etc/ntp.conf chkconfig ntpd on reboot
centos7
作用:配置ip、yum源、chrony、关闭selinux、firewalld
#!/bin/bash # configure network cat >/etc/sysconfig/network-scripts/ifcfg-ens33<<EOF DEVICE=ens33 TYPE=Ethernet ONBOOT=yes BOOTPROTO=static IPADDR=192.168.126.20 PREFIX=24 GATEWAY=192.168.126.2 DNS1=114.114.114.114 EOF # configure yum [ -e /yum ]|| mkdir /yum [ -e /dev/cdrom ]&& mount /dev/cdrom /yum echo "/dev/cdrom /yum iso9660 defaults 0 0" >>/etc/fstab mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/Cen* /etc/yum.repos.d/bak/ cat > /etc/yum.repos.d/local.repo <<EOF [local] name=local baseurl=file:///yum enabled=1 gpgcheck=0 EOF yum clean all yum makecache yum -y install lsof wget sysstat vim lftp chrony bash-completion xorg-x11-xauth # configure ssh sed -i 's/^GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config sed -i '/UseDNS/c\UseDNS no' /etc/ssh/sshd_config # configure firewalld selinux sed -i '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config systemctl disable firewalld systemctl disable NetworkManager # configure chrony sed -i 's/^server/#server/' /etc/chrony.conf echo "server time1.aliyun.com iburst" >> /etc/chrony.conf echo "server time2.aliyun.com iburst" >> /etc/chrony.conf systemctl enable chronyd chmod a+x /etc/rc.d/rc.local reboot