配置虚拟机连接网络

首先确保NetworkManager服务正常运行

[root@administrator ~]# systemctl status  NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-08-07 00:21:59 EDT; 2min 58s ago
Main PID: 1192 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
└─1192 /usr/sbin/NetworkManager --no-daemon Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0-nic): dev...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0): device ...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0-nic): dev...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0): device ...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> NetworkManager st...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0): Activat...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0-nic): dev...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0-nic): Act...
Aug 07 00:22:09 administrator NetworkManager[1192]: <info> (virbr0-nic): lin...
Aug 07 00:22:14 administrator NetworkManager[1192]: <info> (virbr0-nic): lin...
Hint: Some lines were ellipsized, use -l to show in full.

PING本机

[root@administrator ~]# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.092 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.091 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.094 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.097 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.094 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.092 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.097 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.100 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.100 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.058 ms
^C
--- 127.0.0.1 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9002ms
rtt min/avg/max/mdev = 0.058/0.091/0.100/0.015 ms

PING百度

[root@administrator ~]# ping baidu.com
ping: unknown host baidu.com

PING百度无法PING通,下面开始配置

两种配置方式:修改配置文件/使用图形界面工具

  1. 修改网卡配置文件

打开配置文件

[root@administrator ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

修改前的原配置文件

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=ea5c55cd-2fcf-4ed8-a31d-90e86fe56925
DEVICE=eno16777736
ONBOOT=no

修改后的配置文件

TYPE=Ethernet
#static/none/dhcp 桥接模式设置为dhcp即可
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yesgi
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=ea5c55cd-2fcf-4ed8-a31d-90e86fe56925
DEVICE=eno16777736
#启用
ONBOOT=yes

重启网络服务

[root@administrator ~]# systemctl restart network

再次PING百度,虚拟机已经能正常上网

[root@administrator ~]# ping baiu.com
PING baiu.com (222.76.218.234) 56(84) bytes of data.
64 bytes from baiu.com (222.76.218.234): icmp_seq=1 ttl=119 time=52.1 ms
64 bytes from baiu.com (222.76.218.234): icmp_seq=2 ttl=119 time=133 ms
64 bytes from baiu.com (222.76.218.234): icmp_seq=3 ttl=119 time=52.1 ms
64 bytes from baiu.com (222.76.218.234): icmp_seq=4 ttl=119 time=50.7 ms
64 bytes from baiu.com (222.76.218.234): icmp_seq=5 ttl=119 time=54.0 ms
64 bytes from baiu.com (222.76.218.234): icmp_seq=6 ttl=119 time=53.3 ms
^C
--- baiu.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5009ms
rtt min/avg/max/mdev = 50.727/65.890/133.046/30.051 ms

设置为固定IP上网

C:\Users\admin>ipconfig

Windows IP Configuration

Wireless LAN adapter Local Area Connection* 2:

   Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : Ethernet adapter VMware Network Adapter VMnet1: Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::55e1:aa5d:1373:732d%19
IPv4 Address. . . . . . . . . . . : 192.168.19.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : Ethernet adapter VMware Network Adapter VMnet8: Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::89ce:2f34:2be5:2f22%20
IPv4 Address. . . . . . . . . . . : 192.168.72.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : DHCP HOST
Link-local IPv6 Address . . . . . : fe80::549b:37ee:8982:a1a0%6
IPv4 Address. . . . . . . . . . . : 192.168.0.104
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1 Tunnel adapter isatap.DHCP HOST: Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : DHCP HOST Tunnel adapter Teredo Tunneling Pseudo-Interface: Connection-specific DNS Suffix . :
IPv6 Address. . . . . . . . . . . : 2001:0:9d38:6abd:2cd8:158e:5422:ffa6
Link-local IPv6 Address . . . . . : fe80::2cd8:158e:5422:ffa6%4
Default Gateway . . . . . . . . . : :: Tunnel adapter isatap.{D7907800-61F5-4BB5-8D20-E1F1ECB51622}: Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : Tunnel adapter isatap.{077C386B-1B8A-408E-9D76-EF1AAA015440}: Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : C:\Users\admin>

从上面看出宿主机的网段在0网段:192.168.0.1(默认网关)

设置在这个网段内即可(确保你设置的ip没有在局域网内已经被使用)

再次修改配置文件为如下配置:

TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.0.254
PREFIX=32
GATEWAY=192.168.0.1
DNS1=114.114.114.114
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=ea5c55cd-2fcf-4ed8-a31d-90e86fe56925
DEVICE=eno16777736
ONBOOT=yes

配置说明

BOOTPROTO:IP地址类型 值为none/static/dhcp,配置为静态ip设置为none或者static
IPADDR:IP地址
ONBOOT:是否启动
PREFIX:掩码长度
DNS1:DNS SERVER
GATEWAY:默认网关

修改完毕后重启网络服务并PING百度已能正常上网

[root@administrator ~]# systemctl restart network
[root@administrator ~]# ping baidu.com
PING baidu.com (180.149.132.47) 56(84) bytes of data.
64 bytes from 180.149.132.47: icmp_seq=1 ttl=54 time=66.2 ms
64 bytes from 180.149.132.47: icmp_seq=2 ttl=54 time=65.3 ms
64 bytes from 180.149.132.47: icmp_seq=3 ttl=54 time=60.6 ms
^C
--- baidu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 60.692/64.111/66.296/2.466 ms
  1. 使用图形界面工具NetworkManager TUI
[root@administrator ~]# nmtui

然后根据图形界面傻瓜式操作即可

关闭防火墙并设置开机自动关闭

查看防火墙状态

[root@administrator ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-08-07 02:44:34 EDT; 6min ago
Main PID: 1025 (firewalld)
CGroup: /system.slice/firewalld.service
└─1025 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Aug 07 02:44:28 administrator systemd[1]: Starting firewalld - dynamic firew....
Aug 07 02:44:34 administrator systemd[1]: Started firewalld - dynamic firewa....
Hint: Some lines were ellipsized, use -l to show in full.

关闭防火墙

[root@administrator ~]# systemctl stop firewalld

设置开机自动关闭

[root@administrator ~]# systemctl disable firewall

再次查看防火墙状态发现已经成功关闭

[root@administrator ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2016-08-07 02:53:09 EDT; 1min 31s ago
Main PID: 1025 (code=exited, status=0/SUCCESS) Aug 07 02:44:28 administrator systemd[1]: Starting firewalld - dynamic firew....
Aug 07 02:44:34 administrator systemd[1]: Started firewalld - dynamic firewa....
Aug 07 02:53:08 administrator systemd[1]: Stopping firewalld - dynamic firew....
Aug 07 02:53:09 administrator systemd[1]: Stopped firewalld - dynamic firewa....
Hint: Some lines were ellipsized, use -l to show in full.

关闭selinux并设置开机自动关闭

临时关闭:本次操作后关闭,下次重启依然会开启

[root@administrator ~]# setenforce 0

永久关闭

[root@administrator ~]# vim /etc/sysconfig/selinux

原配置文件

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

修改为

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

设置光盘开机自动挂载

[root@administrator ~]# vim /etc/fstab

原配置文件

#
# /etc/fstab
# Created by anaconda on Sun Aug 7 08:42:09 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=b2cf3412-1b3b-48b7-a16a-d971b50b1660 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0

在最后添加下面的配置保存退出

/dev/cdrom              /mnt                    iso9660 defaults        0 0

验证并查看是否挂载成功

[root@administrator ~]# mount -a
mount: /dev/sr0 is write-protected, mounting read-only
[root@administrator ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/rhel-root 49746196 3244372 46501824 7% /
devtmpfs 1001236 0 1001236 0% /dev
tmpfs 1016776 144 1016632 1% /dev/shm
tmpfs 1016776 9144 1007632 1% /run
tmpfs 1016776 0 1016776 0% /sys/fs/cgroup
/dev/sda1 508588 143104 365484 29% /boot
tmpfs 203356 4 203352 1% /run/user/42
tmpfs 203356 16 203340 1% /run/user/0
/dev/sr0 3947824 3947824 0 100% /mnt

配置本地yum源

配置本地yum源之前先挂载系统盘

切换到/etc/yum.repos.d/目录下,删除该目录下的所有文件(请勿在真机操作:先备份)

[root@administrator yum.repos.d]# cd /etc/yum.repos.d/
[root@administrator yum.repos.d]# rm -rf *
[root@administrator yum.repos.d]# ll
total 0

创建yum源配置文件

[root@administrator yum.repos.d]# vim redhat.repo

添加以下内容 保存退出

[local-repository]
name=local-repository
baseurl=file:///mnt
enabled=1
gpgcheck=0

查看以下刚才编辑的内容

administrator yum.repos.d]# cat local.repo
[local-repository]
name=local-repository
baseurl=file:///mnt
enabled=1
gpgcheck=0

清空yum缓存

[root@administrator yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: local-repository
Cleaning up everything

生成缓存列表(软件包的数量上千个,只截取了前面几个)

[root@administrator yum.repos.d]# yum list
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
local-repository | 4.1 kB 00:00
(1/2): local-repository/group_gz | 136 kB 00:00
(2/2): local-repository/primary_db | 3.6 MB 00:00
Installed Packages
GConf2.x86_64 3.2.6-8.el7 @anaconda/7.2
ModemManager.x86_64 1.1.0-8.git20130913.el7 @anaconda/7.2
ModemManager-glib.x86_64 1.1.0-8.git20130913.el7 @anaconda/7.2
NetworkManager.x86_64 1:1.0.6-27.el7 @anaconda/7.2
NetworkManager-adsl.x86_64 1:1.0.6-27.el7 @anaconda/7.2

统计上面操作的结果行数:大约有4000个以上的软件包

[root@administrator yum.repos.d]# yum list | wc -l
4734

创建快照

上述步骤全部操作完毕后,使用VMWare Workstation创建一个快照供以后使用

RHEL7虚拟机实验快照的更多相关文章

  1. Service系统服务(一):安装一个KVM服务器、KVM平台构建及简单管理、virsh基本管理操作、xml配置文件的应用、为虚拟机制作快照备份、快建新虚拟机

    一.安装一个KVM服务器 目标: 本例要求准备一台 RHEL7.2 服务器,将其搭建为KVM平台,主要完成下列操作: 1> 关闭本机的SELinux保护.防火墙服务   2> 挂载RHEL ...

  2. XenServer中虚拟机和快照导出与导入

    我们在工作中经常会遇到,把Xenserver中的虚拟机或者快照导出,然后导入到另一台Xenserver,或者导出来备份下来,以防虚拟机出现故障. 下面介绍一下用xe命令如何导出/导入虚拟机或快照,当然 ...

  3. RHEL7虚拟机添加新网卡后,网卡无法启动

    RHEL7虚拟机添加新网卡后,网卡无法启动 1.在开启网络时,有错误提示: # systemctl restart network.service Job for network.service fa ...

  4. KVM虚拟机建立快照

    部分转载: http://blog.csdn.net/gg296231363/article/details/6899533 windows虚拟机默认镜像格式为raw,快照默认格式为qcow2.win ...

  5. VMware 虚拟化编程(9) — VMware 虚拟机的快照

    目录 目录 前文列表 VMware 虚拟机的快照 快照的执行过程 删除快照 快照类型 Quiseced Snapshot 前文列表 VMware 虚拟化编程(1) - VMDK/VDDK/VixDis ...

  6. 管理员技术(一):装机预备技能、安装一台RHEL7虚拟机、使用RHEL7图形桌面、Linux命令行基本操作

    一.装机预备技能 问题: 本例要求安装一台可用的KVM服务器:      1> RHEL与CentOS系统有什么关联?      2> 第2块SCSI硬盘的第3个逻辑分区,Linux如何表 ...

  7. GNS3通过“云”连接到虚拟机实验

    GNS3通过"云"连接到虚拟机实验并使用wireshark工具对数据分析 观看本文之前注意!!!!! 做这次实验,我所遇到的问题,会全部写在文章结尾,如果读者们遇到问题,可查看. ...

  8. 『学了就忘』Linux基础 — 9、虚拟机中快照的使用

    目录 1.快照的含义 2.快照的使用 步骤一:创建拍摄快照 步骤二:填写快照信息并创建 步骤三:查看快照 步骤四:操作快照 3.管理虚拟机小技巧 4.关于快照说明 快照和克隆是VMware中两个非常实 ...

  9. 迁移虚拟机打开快照报错:CPUID错误

    场景:迁移虚拟机后,恢复快照报错 这个没办法解决,正常启动不会报错,恢复快照有可能报错,是因为你的cpu与快照那个cpu不匹配造成的

随机推荐

  1. Eclipse启动分析

    最近研究了一下Eclipse的启动过程,查了点资料,也有点收获.下面是搜集到的一个比较好的说明,共享下... 在Eclipse启动过程中,Eclipse.exe负责启动,也就是把startup.jar ...

  2. 使用Python画ROC曲线以及AUC值

    from:http://kubicode.me/2016/09/19/Machine%20Learning/AUC-Calculation-by-Python/ AUC介绍 AUC(Area Unde ...

  3. ruby -- 问题解决(四)编码错误导致无法显示(2)

    从数据库中取得数据显示时报 incompatible character encodings: GBK and ASCII-8BIT或 incompatible character encodings ...

  4. 伸展树(三)之 Java的实现

    概要 前面分别通过C和C++实现了伸展树,本章给出伸展树的Java版本.基本算法和原理都与前两章一样.1. 伸展树的介绍2. 伸展树的Java实现(完整源码)3. 伸展树的Java测试程序 转载请注明 ...

  5. Unity 3D 中自动寻路 和 跟随转向 探析

    这里主要讲三个函数 , 一个自动跟随函数 和 两个指向旋转函数 , 这三个函数在游戏角色创建过程中会经常用到: 这个是跟随函数 和 欧拉角旋转函数 public class GensuiZhixian ...

  6. How can I exclude directories from grep -R?

    ‘--exclude-dir=dir’ Exclude directories matching the pattern dir from recursive directory searches. ...

  7. 云计算之路-阿里云上:消灭“黑色n秒”第二招——给w3wp进程指定CPU核

    虽然昨天的第一招失败了,但是从失败中我们学到了与多核CPU相关的Processor Affinity(处理器关联)的知识. 既然我们可以让.NET程序的不同线程运行于指定的CPU核,那是不是也可以让I ...

  8. iOS-定时器

    一.定时器的作用 在软件开发过程中,我们常常需要在某个时间后执行某个方法,或者是按照某个周期一直执行某个方法.在这个时候,我们就需要用到定时器. 二.定时器的种类 大概有三种方法:NSTimer.CA ...

  9. java io系列15之 DataOutputStream(数据输出流)的认知、源码和示例

    本章介绍DataOutputStream.我们先对DataOutputStream有个大致认识,然后再深入学习它的源码,最后通过示例加深对它的了解. 转载请注明出处:http://www.cnblog ...

  10. UICollectionView使用以及与UITableView的区别

    在开始前我们在这先附一段最简单的代码 - (void)viewDidLoad { [super viewDidLoad]; UICollectionViewFlowLayout *layout = [ ...