Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save liyang85/62498f9cd75e92dc8216167f92266969 to your computer and use it in GitHub Desktop.
Save liyang85/62498f9cd75e92dc8216167f92266969 to your computer and use it in GitHub Desktop.
最小化安装CentOS 6.9之后的必要设置
# Part 1: network
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.ori
sed -i 's/ONBOOT=no/ONBOOT=yes/; s/BOOTPROTO=dhcp/BOOTPROTO=none/' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '$a IPADDR=192.168.6.240\nPREFIX=24\nGATEWAY=192.168.6.1' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '$a DNS1=223.5.5.5\nDNS2=119.29.29.29' /etc/sysconfig/network-scripts/ifcfg-eth0
ifdown eth0 && ifup eth0
# If you use a VMware cloned virtual machine, you'll see an error:
# `Device eth0 does not seem to be present, delaying initialization.`, you can change DEVICE name and HWADDR to solve it.
cat /etc/udev/rules.d/70-persistent-net.rules
# The output contains a field like `ATTR{address}="00:11:22:33:44:55"` is HWADDR,
# but there are more than one HWADDR, you need to find the right one by comparing with MAC from VMware settings.
# The output contains a filed like `NAME="eth1"` is DEVICE name
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i 's/^DEVICE.*$/DEVICE=eth1; s/^HWADDR.*$/HWADDR=00:11:22:33:44:55/' /etc/sysconfig/network-scripts/ifcfg-eth1
ifdown eth1 && ifup eth1
# If your VM's NIC has been set to NAT mode, you just need below 2 lines:
sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-eth0
ifdown eth0 && ifup eth0
# Part 2: yum repo
# change default repo from centos.org to 163.com (for Chinese user ONLY)
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.ori
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum update -y
# Part 3: essential packages
yum groupinstall "Base" "Compatibility libraries" "Development tools" "Debugging Tools"
yum install tree telnet dos2unix sysstat lrzsz nc nmap -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment