目录
安全策略配置(防火墙和selinux)
systemctl stop firewalld && systemctl disable firewalld
sed -i s/SELINUX=disabled/SELINUX=enforcing/ /etc/sysconfig/selinux
内核修改(修改网卡名字)
sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/sysconfig/selinux
sed -i s@GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rhgb quiet"@GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rhgb quiet net.ifnames=0"@ /etc/sysconfig/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
rm -rf /etc/sysconfig/network-scripts/ifcfg-eth0
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOf
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.138.11
PREFIX=24
GATEWAY=192.168.138.2
DNS1=192.168.138.2
EOF
配置yun源
echo "/dev/sr0 /mnt iso9660 defaults 0 0" >> /etc/fstab
mount -a
cat > /etc/yum.repos.d/local.repo <<EOF
[local]
name=local
baseurl=file:///mnt
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
总结
#!/bin/bash
systemctl stop firewllad && systemclt disable firewalld
sed -i s/SELINUX=disabled/SELINUX=enforcing/ /etc/sysconfig/selinux
sed -i s/SELINUX=disabled/SELINUX=enforcing/ /etc/sysconfig/selinux
sed -i s@GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rhgb quiet"@GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rhgb quiet net.ifnames=0"@ /etc/sysconfig/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
mv /etc/sysconfig/network-scripts/ifcfg-en* /etc/sysconfig/network-scripts/ifcfg-eth0
echo "TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.138.11 # 这是内网地址
PREFIX=24
GATEWAY=192.168.138.2 # 这是网关
DNS1=192.168.138.2" >/etc/sysconfig/network-scripts/ifcfg-eth0
echo "/dev/sr0 /mnt iso9660 defaults 0 0" >> /etc/fstab
mount -a
cat > /etc/yum.repos.d/local.repo <<EOF
[local]
name=local
baseurl=file:///mnt
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
reboot