第一步:网络连接模式的选择
第二步
第三步
第四步(点击VMnet8)
第五步(点击第四步的"NAT设置",得到网关地址)
第六步(点击第四步的"DHCP设置",得到子网掩码和能配置ip地址的范围,之后点击"确定")
第七步
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vim ifcfg-ens33
修改或添加如下代码:
(1)
BOOTPROTO=static
ONBOOT=yes
(2)第六步得到的ip范围中选一个,子网掩码照抄
IPADDR=192.168.11.200
NETMASK=255.255.255.0
(3)第5步得到的网关
GATEWAY=192.168.11.2
(4)暂时固定(如果不行,将其改为网关的数据,如上192.168.11.2)
DNS1=192.168.11.2
或DNS1=144.144.144.144
第8步
(1)重启网络服务
service network restart或
systemctl restart network
(2)关闭window和centos防火墙
centos:
(1)查看centos防火墙的状态: systemctl status firewalld
输出的结果中如果有:
Active: active (running)表示防火墙开启了
(2)关闭防火墙: service firewalld stop
在输出的结果中可以看到:
Active: inactive (dead)
第9步
可能是dns的配置
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 114.114.114.114
第10步
(1)虚拟机与主机之间ping:
[root@localhost network-scripts]# ping 192.168.99.199
PING 192.168.99.199 (192.168.99.199) 56(84) bytes of data.
64 bytes from 192.168.99.199: icmp_seq=1 ttl=128 time=0.568 ms
64 bytes from 192.168.99.199: icmp_seq=2 ttl=128 time=1.12 ms
64 bytes from 192.168.99.199: icmp_seq=3 ttl=128 time=1.08 ms
64 bytes from 192.168.99.199: icmp_seq=4 ttl=128 time=0.915 ms
64 bytes from 192.168.99.199: icmp_seq=5 ttl=128 time=0.897 ms
64 bytes from 192.168.99.199: icmp_seq=6 ttl=128 time=1.12 ms
(2)主机ping虚拟机
ping 192.168.11.200
正在 Ping 192.168.11.200 具有 32 字节的数据:
来自 192.168.11.200 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.11.200 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.11.200 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.11.200 的回复: 字节=32 时间<1ms TTL=64
192.168.11.200 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
(3)虚拟机ping百度
[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=128 time=4.42 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=2 ttl=128 time=4.37 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=3 ttl=128 time=5.45 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=4 ttl=128 time=4.79 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=5 ttl=128 time=5.10 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=6 ttl=128 time=5.58 ms
第九步(ssl连接需要勾选下图)
添加ifconfig命令
yum install net-tools.x86_64
修改主机名和ip绑定
[root@n2 ~]# cat /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.5.201 n1
192.168.5.202 n2
192.168.5.203 n3
192.168.5.204 n4