赞
踩
vi /etc/sysconfig/network-scripts/ifcfg-ens33进入网卡配置文件
将BOOTPROTO=dhcp改为
BOOTPROTO=static
ONBOOT=no
该为ONBOOT=yes
在文档末尾加上:
IPADDR=192.168.200.10
PREFIX=24
GATEWAY=192.168.200.1
DNS1=114.114.114.114
DNS2=8.8.8.8
最后按“esc”键再按“shift”加“:”号进入末行模式输入wq或x保存退出
退出文档后输入systemctl restart network重启网络服务再用IP a查看网络是否配上。
可以输入ping www.baidu.com(NAT模式)或ping 本地ip(仅主机模式)检查是否连通互联网
如图若ping不通可检查VMware虚拟网络编辑器是否配置成功或虚拟机是否选择对网络
如果都是正常的则查看本地网卡是否打开和IP配置正确
选择更改适配器选项
打开网卡并查看IP是否完整
打开配置完成回到虚拟机内再次ping www.baidu.com
ifconfig ens32 192.168.100.10 netmask 255.255.255.0 up
其中,ens32是网卡接口名,192.168.100.10是临时ip,255.255.255.0是子网掩码。
ip addr add 192.168.100.10/24 dev ens32
其中,192.168.100.10是临时ip,/24是子网掩码,ens32是网卡接口名。
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1664 Apr 29 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr 29 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Apr 29 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Apr 29 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Apr 29 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr 29 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 Apr 29 2018 CentOS-Vault.repo
[root@localhost yum.repos.d]# yum install wget -y
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): base/7/x86_64/primary_db | 6.1 MB 00:00:01
(3/4): updates/7/x86_64/primary_db | 25 MB 00:00:02
(4/4): extras/7/x86_64/primary_db | 250 kB 00:00:05
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency ResolutionDependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 base 547 kTransaction Summary
=====================================================================================================================================
Install 1 PackageTotal download size: 547 k
Installed size: 2.0 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for wget-1.14-18.el7_6.1.x86_64.rpm is not installed
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1Installed:
wget.x86_64 0:1.14-18.el7_6.1Complete!
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2024-03-21 16:20:47-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 222.186.18.240, 222.186.18.249, 222.186.18.243, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|222.186.18.240|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’100%[===========================================================================================>] 2,523 --.-K/s in 0.005s
2024-03-21 16:20:47 (487 KB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
base/7/x86_64/primary_db FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
(1/10): extras/7/x86_64/filelists_db | 303 kB 00:00:00
(2/10): extras/7/x86_64/other_db | 150 kB 00:00:00
(3/10): base/7/x86_64/other_db | 2.6 MB 00:00:05
(4/10): base/7/x86_64/group_gz | 153 kB 00:00:05
base/7/x86_64/filelists_db FAILED ] 495 kB/s | 13 MB 00:01:32 ETA
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
updates/7/x86_64/primary_db FAILED ] 794 kB/s | 18 MB 00:00:51 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/9c12a6244db35e0d9ba3110b417fc06e8a28196a9bdd43d5e22c48d99b39e619-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
extras/7/x86_64/primary_db FAILED
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/0a5413843d4b238fd3894be760ed384be82139b517ce77a3a71a7b3c6a774a8b-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
updates/7/x86_64/other_db FAILED ] 804 kB/s | 18 MB 00:00:50 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/e0d48c92924acb5a143913514c9ff85d07af23813a70c4d0577fa4862d95f1f9-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(5/10): extras/7/x86_64/primary_db | 250 kB 00:00:00
(6/10): updates/7/x86_64/filelists_db | 14 MB 00:00:29
(7/10): updates/7/x86_64/other_db | 1.5 MB 00:00:03
(8/10): base/7/x86_64/primary_db | 6.1 MB 00:00:13
(9/10): base/7/x86_64/filelists_db | 7.2 MB 00:00:21
(10/10): updates/7/x86_64/primary_db | 25 MB 00:00:56
Metadata Cache Created
[root@localhost yum.repos.d]# yum install -y epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency ResolutionDependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 kTransaction Summary
=====================================================================================================================================
Install 1 PackageTotal download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1Installed:
epel-release.noarch 0:7-11Complete!
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 6.9 kB 00:00:00
* base: mirrors.aliyun.com
* epel: mirror.nju.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/16): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/16): base/7/x86_64/primary_db | 6.1 MB 00:00:12
(3/16): epel/x86_64/group_gz | 100 kB 00:00:00
(4/16): epel/x86_64/prestodelta | 576 B 00:00:00
(5/16): epel/x86_64/primary_db | 7.0 MB 00:00:00
(6/16): epel/x86_64/other_db | 3.4 MB 00:00:00
(7/16): epel/x86_64/updateinfo | 1.0 MB 00:00:01
(8/16): base/7/x86_64/filelists_db | 7.2 MB 00:00:14
(9/16): extras/7/x86_64/filelists_db | 303 kB 00:00:00
(10/16): extras/7/x86_64/primary_db | 250 kB 00:00:00
(11/16): extras/7/x86_64/other_db | 150 kB 00:00:00
(12/16): base/7/x86_64/other_db | 2.6 MB 00:00:05
epel/x86_64/filelists_db FAILED ] 1.1 MB/s | 40 MB 00:00:37 ETA
http://mirrors.bfsu.edu.cn/epel/7/x86_64/repodata/08fcf9bca1a2332b4e1190ee6d67024320852f462bee4866bc38ee676f0aae7e-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2409:8700:2482:710::fe55:2840: Network is unreachable"
Trying other mirror.
(13/16): updates/7/x86_64/filelists_db | 14 MB 00:00:30
(14/16): epel/x86_64/filelists_db | 12 MB 00:00:01
(15/16): updates/7/x86_64/other_db | 1.5 MB 00:00:03
(16/16): updates/7/x86_64/primary_db | 25 MB 00:00:56
Metadata Cache Created
[root@localhost yum.repos.d]# yum install -y sl
[root@localhost yum.repos.d]# sudo yum install -y sl
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# df /mnt/cdrom
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 38770180 1032416 37737764 3% /
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# df -hT /mnt/cdrom
Filesystem Type Size Used Avail Use% Mounted on
/dev/sr0 iso9660 4.2G 4.2G 0 100% /mnt/cdrom
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1664 Apr 29 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr 29 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Apr 29 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Apr 29 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Apr 29 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr 29 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 Apr 29 2018 CentOS-Vault.repo
[root@localhost yum.repos.d]# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
改为:
[root@localhost yum.repos.d]# vi CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command][c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7~
4.清除yum缓存,测试yum源配置
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: c7-media
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
5 下载一个apache测试
[root@localhost yum.repos.d]# yum -y install httpd
Loaded plugins: fastestmirror
Determining fastest mirrors
c7-media | 3.6 kB 00:00:00
(1/2): c7-media/group_gz | 166 kB 00:00:00
(2/2): c7-media/primary_db | 3.1 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-80.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-80.el7.centos for package: httpd-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-80.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-80.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-80.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
httpd x86_64 2.4.6-80.el7.centos c7-media 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-3.el7_4.1 c7-media 103 k
apr-util x86_64 1.5.2-6.el7 c7-media 92 k
httpd-tools x86_64 2.4.6-80.el7.centos c7-media 89 k
mailcap noarch 2.1.41-2.el7 c7-media 31 kTransaction Summary
出现这种界面表示配置成功
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。