VMware VMnet8 模式共享主机网络配置静态 IP 和 DNS

一、简介

NAT网络模式:

1. 宿主机可以看做一个路由器,虚拟机通过宿主机的网络来访问  Internet;

2. 可以安装多台虚拟机,组成一个小型局域网,例如:搭建 hadoop 集群、分布式服务。

二、配置

1. VMnet8 设置静态 IP

2. Centos 网络设配器为 NAT 模式

3. VMware 虚拟网络设置

4. 启动虚拟机

5. 修改网络设置

先查看网卡名称

# ip addr

进入 network-scripts 目录找到 ifcfg-ens33 文件

# cd /etc/sysconfig/network-scripts/
# ls

编辑 ifcfg-ens33 文件,修改配置

# vi ifcfg-ens33

修改
BOOTPROTO=static           # 使用静态 IP
新增
IPADDR=192.168.5.100       # 设置 IP
NETMASK=255.255.255.0      # 子网掩码
GATEWAY=192.168.5.2        # 网关
DNS1=192.168.5.2           # DNS
NM_CONTROLLED=no           # network mamager 的参数,实时生效,不需要重启 ONBOOT=yes

6. 重启 network

# systemctl restart network
或者
# service network restart

7. 验证结果,看到下图结果,即共享主机网络设置成功

# ping www.baidu.com

 

  • 28
    点赞
  • 123
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
vmnet8VMware 中默认的 NAT 网络,它可以为虚拟机提供 NAT 服务,使其可以与主机和其他虚拟机相互通信,同时也可以访问外部网络。下面是配置 VMwarevmnet8 NAT 的步骤: 1. 在主机上找到 VMware 安装目录,进入 "networking" 文件夹,找到 "nat.conf" 文件。 2. 使用文本编辑器打开 "nat.conf" 文件,在文件末尾添加以下内容: ``` [incomingtcp] # Use these with care - anyone can enter into your VM through these... # The format and example are as follows: #<external port number> = <VM's IP address>:<VM's port number> #8080 = 192.168.39.129:80 [incomingudp] # Use these with care - anyone can enter into your VM through these... # The format and example are as follows: #<external port number> = <VM's IP address>:<VM's port number> [outgoingtcp] # Use these with care - anyone can enter into your VM through these... # The format and example are as follows: #<VM's IP address>:<VM's port number> = <external port number> #192.168.39.129:80 = 8080 [outgoingudp] # Use these with care - anyone can enter into your VM through these... # The format and example are as follows: #<VM's IP address>:<VM's port number> = <external port number> ``` 3. 修改上述配置文件中的端口映射规则,将外部端口与虚拟机的 IP 地址和端口号对应起来。例如,将外部的 8080 端口映射到虚拟机的 192.168.39.129:80 端口上。 4. 保存 "nat.conf" 文件后,重启 VMware Workstation 服务或者重启主机,让新的配置生效。 5. 在虚拟机中,使用 DHCP 自动获取 IP 地址,或者手动配置 IP 地址和默认网关,确保虚拟机与主机和其他虚拟机在同一局域网内。 6. 如果需要访问外部网络,可以在虚拟机中配置默认网关和 DNS 服务器,或者在 NAT 配置中添加端口转发规则,将虚拟机的网络流量转发到主机或其他外部网络中。 需要注意的是,vmnet8VMware 中默认的 NAT 网络,如果修改了默认的 NAT 配置,可能会影响其他虚拟机的网络通信。因此,在修改 NAT 配置时,需要谨慎处理,并且备份原始配置文件,以便在出现问题时进行恢复。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值