7/12/2017 - 4:27 PM

最小化安装CentOS 6.9之后的必要设置

最小化安装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=\nPREFIX=24\nGATEWAY=' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '$a DNS1=\nDNS2=' /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 to (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
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