VirtualBox配置Centos網絡和域名解析

VirtualBox虛擬機和Centos系統地址

VirtualBox:https://download.virtualbox.org/virtualbox/5.2.16/VirtualBox-5.2.16-123759-Win.exe
Centos:http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso

VirtualBox安裝Centos

https://blog.csdn.net/GY325416/article/details/79300621

Centos配置靜態ip

在windows使用win+r鍵,輸入cmd打開控制窗口,鍵入ipconfig命令,查看電腦的ip
這裏寫圖片描述

進入虛擬機,編輯ifcfg-enp文件,來配置網絡
vi /etc/sysconfig/network-scripts/ifcfg-*
這裏寫圖片描述

配置ip爲192.168.1.201
這裏寫圖片描述
保存過後,重啓網絡服務(service network restart)
使用ip addr指令查看ip地址已經變更

這時在windows系統,ping 192.168.1.201發現不能ping通,還需要配置一項
這裏寫圖片描述

再試一次就能ping通了

Centos配置域名解析

雖然windows可以ping centos了,但是在centos裏面ping www.baidu.com發現停滯不前,這時因爲沒有配置域名解析器
打開網絡配置文件,如下配置DNS1
這裏寫圖片描述