Mac 上 VMware 设置虚拟机为静态 IP
2021/7/10 7:07:51
本文主要是介绍Mac 上 VMware 设置虚拟机为静态 IP,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1. 查看本机网关和子网掩码
-
进入 Mac 的 Temical,输入:
$ cd /Library/Preferences/VMware\ Fusion/vmnet8 $ ll total 32 -rw-r--r-- 1 root wheel 1665 6 30 11:00 dhcpd.conf -rw-r--r-- 1 root wheel 1665 6 30 11:00 dhcpd.conf.bak -rw-r--r-- 1 root wheel 1682 6 30 11:00 nat.conf -rw-r--r-- 1 root wheel 1682 6 30 11:00 nat.conf.bak
-
查看
nat.conf
内容:$ cat nat.conf # VMware NAT configuration file # Manual editing of this file is not recommended. Using UI is preferred. [host] # Use MacOS network virtualization API useMacosVmnetVirtApi = 1 # NAT gateway address ip = xxx.xxx.xxx.xxx #这个 ip 就是本机网关地址 netmask = 255.255.255.0 #这个就是本机子网掩码
网关地址:xxx.xxx.xxx.xxx
子网掩码:255.255.255.0
-
查看
dhcpd.conf
内容:subnet xxx.xxx.xxx.0 netmask 255.255.255.0 { range xxx.xxx.xxx.128 xxx.xxx.xxx.254 ; # range 这个是虚拟机允许选择的静态ip地址范围,自定义的静态ip地址必须要在这个范围内 option broadcast-address xxx.xxx.xxx.xxx ; option domain-name-servers xxx.xxx.xxx.xxx ; option domain-name localdomain; default-lease-time 1800; # default is 30 minutes max-lease-time 7200; # default is 2 hours option netbios-name-servers xxx.xxx.xxx.xxx ; option routers xxx.xxx.xxx.xxx ; }
得到静态 IP 访问:
xxx.xxx.xxx.128 - xxx.xxx.xxx.254
2. 查看本机 DNS
-> 系统偏好设置 -> 网络 -> 高级 -> DNS -> DNS 服务器
3. 修改虚拟机静态 IP
-
进入虚拟机的
network-scripts
目录:$ cd /etc/sysconfig/network-scripts/ $ ls ifcfg-ens33 ifdown-isdn ifup ifup-plip ifup-tunnel ifcfg-lo ifdown-post ifup-aliases ifup-plusb ifup-wireless ifdown ifdown-ppp ifup-bnep ifup-post init.ipv6-global ifdown-bnep ifdown-routes ifup-eth ifup-ppp network-functions ifdown-eth ifdown-sit ifup-ib ifup-routes network-functions-ipv6 ifdown-ib ifdown-Team ifup-ippp ifup-sit ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort
-
找到
ifcfg-en
开头的文件,上图中我的是ifcfg-ens33
-
使用 root 权限编辑
ifcfg-ens33
: -
保存
-
重启无网络服务,使配置生效:
$ service network restart Restarting network (via systemctl): [ OK ]
4. 检查配置是否成功
-
看控制面板:
-
虚拟机上 ping 一下百度看看能不能成功:
$ ping www.baidu.com PING www.a.shifen.com (180.101.49.12) 56(84) bytes of data. 64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=1 ttl=38 time=36.9 ms 64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=2 ttl=38 time=39.5 ms 64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=3 ttl=38 time=43.0 ms
-
主机 ping 一下虚拟机看看:
$ ping xxx.xxx.xxx.201 PING xxx.xxx.xxx.201 (xxx.xxx.xxx.201): 56 data bytes 64 bytes from xxx.xxx.xxx.201: icmp_seq=0 ttl=64 time=0.317 ms 64 bytes from xxx.xxx.xxx.201: icmp_seq=1 ttl=64 time=0.415 ms 64 bytes from xxx.xxx.xxx.201: icmp_seq=2 ttl=64 time=0.453 ms
-
没有问题,配置完成。
这篇关于Mac 上 VMware 设置虚拟机为静态 IP的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15PingCAP 黄东旭参与 CCF 秀湖会议,共探开源教育未来
- 2024-05-13PingCAP 戴涛:构建面向未来的金融核心系统
- 2024-05-09flutter3.x_macos桌面os实战
- 2024-05-09Rust中的并发性:Sync 和 Send Traits
- 2024-05-08使用Ollama和OpenWebUI在CPU上玩转Meta Llama3-8B
- 2024-05-08完工标准(DoD)与验收条件(AC)究竟有什么不同?
- 2024-05-084万 star 的 NocoDB 在 sealos 上一键起,轻松把数据库编程智能表格
- 2024-05-08Mac 版Stable Diffusion WebUI的安装
- 2024-05-08解锁CodeGeeX智能问答中3项独有的隐藏技能
- 2024-05-08RAG算法优化+新增代码仓库支持,CodeGeeX的@repo功能效果提升