欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

VMwareFusion虚拟机配置固定IP

时间:2023-05-19
文章目录

物理机设置

关闭VM的DHCP查看网关和DNS 虚拟机配置

设置静态IP重启网卡其他 物理机设置 关闭VM的DHCP

sudo vim /Library/Preferences/VMware Fusion/networking# 关闭answer VNET_8_DHCP no

查看网关和DNS

vim /Library/Preferences/VMware Fusion/vmnet8/dhcpd.confsubnet 172.16.227.0 netmask 255.255.255.0 { range 172.16.227.128 172.16.227.254; # 可选的静态ip的范围 option broadcast-address 172.16.227.255; # 广播地址,也是我们的默认网关地址 option domain-name-servers 172.16.227.2; # DNS地址 option domain-name localdomain; default-lease-time 1800; # default is 30 minutes max-lease-time 7200; # default is 2 hours option netbios-name-servers 172.16.227.2; option routers 172.16.227.2;}host vmnet8 { hardware ethernet 00:50:56:C0:00:08; fixed-address 172.16.227.1; option domain-name-servers 0.0.0.0; option domain-name ""; option routers 0.0.0.0;}

虚拟机配置 设置静态IP

# 1.查看使用的虚拟网卡ip addr# centos7vim /etc/sysconfig/network-scripts/ifcfg-ens33TYPE="Ethernet"BOOTPROTO="dhcp"DEFROUTE="yes"PEERDNS="yes"PEERROUTES="yes"IPV4_FAILURE_FATAL="no"IPV6INIT="yes"IPV6_AUTOCONF="yes"IPV6_DEFROUTE="yes"IPV6_PEERDNS="yes"IPV6_PEERROUTES="yes"IPV6_FAILURE_FATAL="no"IPV6_ADDR_GEN_MODE="stable-privacy"NAME="ens33"UUID="90a04425-edae-48cf-92c1-a2ed90b8b4a2"DEVICE="ens33"ONBOOT="yes"# 在最后加上:IP地址、子网掩码、网关、dns服务器IPADDR=172.16.227.131NETMASK=255.255.255.0GATEWAY=172.16.227.0DNS1=172.16.227.2

重启网卡

# 重启虚拟机网卡systemctl restart network# 查看IP是否配置成功ip addr

其他

ip addr可以看到所有IP,ifconfig看不到。

[wangfugui@localhost ~]$ ifconfigens33: flags=4163 mtu 1500 inet 172.16.227.137 netmask 255.255.255.0 broadcast 172.16.227.255 inet6 fe80::1483:12b2:5fc0:f209 prefixlen 64 scopeid 0x20 ether 00:0c:29:cf:db:9d txqueuelen 1000 (Ethernet) RX packets 1535 bytes 190117 (185.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 771 bytes 82971 (81.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[wangfugui@localhost ~]$ ip addr2: ens33: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:cf:db:9d brd ff:ff:ff:ff:ff:ff inet 172.16.227.137/24 brd 172.16.227.255 scope global dynamic ens33 # 动态IP valid_lft 1651sec preferred_lft 1651sec inet 172.16.227.129/24 brd 172.16.227.255 scope global secondary ens33 # 固定IP valid_lft forever preferred_lft forever inet6 fe80::1483:12b2:5fc0:f209/64 scope link valid_lft forever preferred_lft forever

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。