[3] CentOS基本设置
一、配置网卡
如果虚拟机复制后,选择“I copied it.”选项后,需要做如下修正网卡配置,才能启动网卡:
# vi /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:66:3f:1f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
:wq
将原eth0配置删除,将eth1改为eth0,同时记录下MAC地址:00:0c:29:66:3f:1f备用。
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
GATEWAY="192.168.203.2" #这里使用VMware NAT,在VMware Workstation-Edit-Visual Network Editor里可以查到,网关为2,宿主windows为1
NETMASK="255.255.255.0"
IPADDR="192.168.203.80" #设置虚拟器IP
DNS1="192.168.203.2" #同GATEWAY
DNS2="8.8.8.8"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE="Ethernet"
UUID="6412b1e9-0772-447d-b0c5-766112465936"
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:0C:29:66:3F:1F #虚拟机复制后此处需要设置成上面记录的MAC地址
PEERDNS=yes
PEERROUTES=yes
LAST_CONNECT=1348783337
:wq
# service network restart
二、配置hostname
# vi /etc/sysconfig/network
HOSTNAME=localhost
:wq
三、禁用selinux
# vi /etc/sysconfig/selinux
SELINUX=disabled
#SELINUXTYPE=targeted
:wq
# reboot
二、yum源
# cd /etc/yum.repos.d/
# mv CentOS-Base.repo CentOS-Base.repo.bak
# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
# mv CentOS-Media.repo CentOS-Media.repo.bak
# mv CentOS-Vault.repo CentOS-Vault.repo.bak
# yum -y install wget
# wget https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2
# yum clean all
# yum makecache
# yum info gcc
三、安装常用命令
# yum -y install traceroute bind-utils telnet net-snmp man ntpdate openssh-clients tree zip unzip mlocate