zoukankan      html  css  js  c++  java
  • centos系统初始化脚本

    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
    本文作者:fcing
    本文出处:https://www.cnblogs.com/fcing
    版权声明:本博客所有文章除特别声明外,均采用CC BY-NC-SA 4.0 许可协议。转载请注明出处!
  • 相关阅读:
    SOCKET 3次握手
    NativeXml帮助(四) http://gaoyanan.blog.sohu.com/162725319.html
    DELPHI下的SOCK编程(转)
    socket 编程入门教程(三)TCP原理:5、TCP的三次握手(threeway handshake)
    计算机术语的英文缩写
    提高查询速度方法总结
    复制表结构的通用存储过程
    QQ盗号工具代码(破解键盘锁)
    使用VB将SQL SERVER 的脚本导出
    2007第四周 关于逛街
  • 原文地址:https://www.cnblogs.com/fcing/p/9349082.html
Copyright © 2011-2022 走看看