!/bin/bash
禁用SElinux
sed -ri.bak '/^SELINUX.ing/s/(.)=(.*)/\1=disabled/' /etc/selinux/config
关闭防火墙
systemctl disable --now firewalld > /dev/null
修改网卡名
sed -ri.bak '/^GRUB_CMDLINE_LINUX/s/(.*)(")/\1 net.ifnames=0\2/' /etc/default/grub
grub2-mkconfig -o /etc/grub2.cfg > /dev/null
ssh登录加速
sed -nr '/^GSSAPIAuthentication/s/#(.) (yes$)/\1 no/p' /etc/ssh/sshd_config
sed -nr '/^GSSAPIAuthentication/s/(.) (yes$)/\1 no/p' /etc/ssh/sshd_config
配置yum源
cd /etc/yum.repos.d/
mkdir backup
mv *.repo backup
cat > base.repo << EOF
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=0
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
enabled=1
gpgcheck=0
EOF
设置静态地址
cd /etc/sysconfig/network-scripts/
cat > ifcfg-eth0 << EOF
DEVICE=eth0
NAME=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.0.0.77
PREFIX=24
GATEWAY=10.0.0.2
DNS1=223.5.5.5
DNS2=114.114.114.114
EOF
reboot