虚拟机安装centos7设置静态ip

虚拟机安装Centos7

一、软件版本

  • 物理宿主机系统:Windows 10 专业版

  • 虚拟机软件:VMware Workstation 15.5.6版本

  • CentOS操作系统ISO镜像:CentOS 7.4 64位

  • SSH终端软件:SecureCRT

  • SFTP文件传输工具:filezilla

二、在虚拟机安装centos7操作系统

1.创建新的虚拟机

[图片上传失败…(image-582e3-1595513155263)]

2、选择虚拟机硬件兼容性

虚拟机安装centos7设置静态ip

默认即可

3、加载Linux系统ISO镜像

虚拟机安装centos7设置静态ip

虚拟机安装centos7设置静态ip

4、虚拟机命名并存储

虚拟机安装centos7设置静态ip

5、自定义虚拟机配置

处理器按需配置:

[图片上传失败…(image-ca28b0-1595513155263)]

内存按需配置:

虚拟机安装centos7设置静态ip

网络部分选择「桥接模式」即可:

虚拟机安装centos7设置静态ip

硬盘类型和I/O控制器选择默认即可:

虚拟机安装centos7设置静态ip

虚拟机安装centos7设置静态ip

硬盘容量类型:

[图片上传失败…(image-9a1c5-1595513155263)]

虚拟机文件名:

虚拟机安装centos7设置静态ip

6、安装设置,开启安装

虚拟机安装centos7设置静态ip

7、进入系统安装界面

虚拟机安装centos7设置静态ip

一直回车即可

8、选择安装语言

虚拟机安装centos7设置静态ip

9、选择预安装的软件

[图片上传失败…(image-42d93-1595513155263)]

虚拟机安装centos7设置静态ip

没有特别需求可以选择自动分区,大家如果有需要可以自定义分区。

10、进入正式安装过程

虚拟机安装centos7设置静态ip

12、安装完成并重启

虚拟机安装centos7设置静态ip

13、进入新系统

虚拟机安装centos7设置静态ip

虚拟机安装centos7设置静态ip

[图片上传失败…(image-a22831-1595513155263)]

网络配置

安装好的centos7默认是没有网络配置的,而且虚拟机中每次重启,网卡ip都会变化,所以要配置linux的网卡,使其有静态ip

1、第一尝试查看虚拟机系统的IP地址

使用命令ifconfig进行查看。

2、设置虚拟机与物理宿主机的网络连接

虚拟机安装centos7设置静态ip

虚拟机安装centos7设置静态ip

  • 仅主机模式只能ping通主机和其他使用同一块网卡仅主机模式的节点不能连外网

  • 桥接模式可以复制宿主机的网络状态,即在宿主机拥有ip时,会拥有同一个网段下的另一个IP(宿主机外访问不到)

    虚拟机安装centos7设置静态ip

  • nat模式会在宿主机的网络环境下拥有另一个ip,并且可以使用宿主机的ip拨号上网连接以太网

3、为虚拟机配置固定静态IP

第一使用dhclient工具为本机分配一个网络内可用的IP地址:

虚拟机安装centos7设置静态ip

接下来编辑虚拟机系统网卡配置,将上面分配所得的IP地址配置进去:

使用命令编辑:vim /etc/sysconfig/network-scripts/ifcfg-ens33

修改配置如下:

<pre spellcheck=”false” class=”md-fences md-end-block ty-contain-cm modeLoaded” lang=”properties” cid=”n84″ mdtype=”fences” style=”box-sizing: border-box; overflow: visible; font-family: var(–font-monospace); font-size: 0.85rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248) !important; position: relative !important; width: inherit; border: 1px solid rgb(244, 244, 244); -webkit-font-smoothing: initial; line-height: 1.43rem; border-radius: 2px; overflow-wrap: normal; margin: 0.8rem 0px !important; padding: 0.3rem 0px !important; color: rgb(52, 73, 94); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;”>TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static # 关闭dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=824ec4bd-a9ae-4410-8346-17ce7f3dd111
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.3.49 # 上一步获得的ip
NETMASK=255.255.255.0
GATEWAY=192.168.3.1 # 网关
DNS1=119.29.29.29</pre>

虚拟机安装centos7设置静态ip

编辑完成,重启网络设置即可

<pre spellcheck=”false” class=”md-fences md-end-block ty-contain-cm modeLoaded” lang=”” cid=”n87″ mdtype=”fences” style=”box-sizing: border-box; overflow: visible; font-family: var(–font-monospace); font-size: 0.85rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248) !important; position: relative !important; width: inherit; border: 1px solid rgb(244, 244, 244); -webkit-font-smoothing: initial; line-height: 1.43rem; border-radius: 2px; overflow-wrap: normal; margin: 0.8rem 0px !important; padding: 0.3rem 0px !important; color: rgb(52, 73, 94); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;”>systemctl restart network.service</pre>

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
雅木的头像 - 宋马
评论 抢沙发

请登录后发表评论

    暂无评论内容