VMware虚拟机配置自己想要的IP
需求: 配置Linux虚拟机的IP为我想要的任意IP(如:192.168.10.11)一、NAT模式下IP,、子网掩码、网关、DNS的配置右击桌面右小角网络图标,点击 打开 “网络和 Internet设置“点击”更改适配器选项“,会看到:VMware Network Adapter VMnet1(仅主机模式) 、 VMware Network Adapter VMnet8 (NAT模式)右击VMw
·
需求: 配置Linux虚拟机的IP为我想要的任意IP(如:192.168.10.11)
一、NAT模式下IP,、子网掩码、网关、DNS的配置
- 右击桌面右小角网络图标,点击 打开 “网络和 Internet设置“
- 点击”更改适配器选项“,会看到:VMware Network Adapter VMnet1(仅主机模式) 、 VMware Network Adapter VMnet8 (NAT模式)
- 右击 VMware Network Adapter VMnet8 - - 属性
- 配置本主机Windows的IP(192.168.10.10)、子网掩码(255.255.255.0)、网关(192.168.10.2)和 DNS服务(8.8.8.8、144.144.144.144)
注意: IP地址 和 默认网关必须在同一个网段。网关的最后一段最好不要设置为0或1,我这里设置的是2。子网掩码和DNS服务器进行如图设置即可。 - VMware虚拟机配置
5.1 打开 VMware Workstation - 编辑 - 虚拟网络编辑器 ,按下图序号进行操作,设置
DHCP的设置如图所示:
5.2 设置你的虚拟机网络适配器为VMnet8(NAT模式)
5.3 开启此虚拟机,设置网卡(ens33)
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="7c080a13-ed61-41a5-a107-fe8ecc2ea84f"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.10.11
NETMASK=255.255.255.0
GATEWAY=192.168.10.2
DNS1=8.8.8.8
DNS2=114.114.114.114
ZONE=public
5.4 重启网络(systemctl restart network)
[root@localhost ~]# systemctl restart network
[root@localhost ~]#
5.5 验证ens33网卡的IP是否为192.168.10.11
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c7:ed:be brd ff:ff:ff:ff:ff:ff
inet 192.168.10.11/24 brd 192.168.10.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::74fc:6ac9:ac81:8fc2/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@localhost ~]#
5.6 验证是否能正常上网
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=76.9 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=146 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=96.5 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=128 time=159 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=128 time=108 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=6 ttl=128 time=303 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=7 ttl=128 time=85.6 ms
^C
--- www.a.shifen.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6061ms
rtt min/avg/max/mdev = 76.903/139.505/303.660/72.708 ms
[root@localhost ~]#
二、仅主机模式下IP,、子网掩码、网关、DNS的配置
- VMware Network Adapter VMnet1 配置如下
- 虚拟网络编辑器 配置如下
- 添加一块网卡(网络适配器2),设置为仅主机模式,并生成MAC地址
- 开启此虚拟机,设置网卡IP(ens37)
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c7:ed:be brd ff:ff:ff:ff:ff:ff
inet 192.168.10.11/24 brd 192.168.10.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::74fc:6ac9:ac81:8fc2/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:50:56:2e:5f:ac brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global noprefixroute dynamic ens37
valid_lft 1781sec preferred_lft 1781sec
inet6 fe80::6488:dd1b:9912:7975/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@localhost ~]#
4.1 查看ens37网卡的uuid
[root@localhost ~]# nmcli con
NAME UUID TYPE DEVICE
ens33 7c080a13-ed61-41a5-a107-fe8ecc2ea84f ethernet ens33
有线连接 1 249c0488-7050-345f-9409-af1908186ce4 ethernet ens37
[root@localhost ~]#
4.2 设置ens37网卡,进入 /etc/sysconfig/network-scripts/ 目录
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-ippp ifdown-routes ifup ifup-ipv6 ifup-ppp ifup-tunnel
ifcfg-lo ifdown-ipv6 ifdown-sit ifup-aliases ifup-isdn ifup-routes ifup-wireless
ifdown ifdown-isdn ifdown-Team ifup-bnep ifup-plip ifup-sit init.ipv6-global
ifdown-bnep ifdown-post ifdown-TeamPort ifup-eth ifup-plusb ifup-Team network-functions
ifdown-eth ifdown-ppp ifdown-tunnel ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6
[root@localhost network-scripts]#
4.3 复制 ifcfg-ens33,重命名为 ifcfg-ens37,编辑 ifcfg-ens37
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens37
[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-eth ifdown-ppp ifdown-tunnel ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6
ifcfg-ens37 ifdown-ippp ifdown-routes ifup ifup-ipv6 ifup-ppp ifup-tunnel
ifcfg-lo ifdown-ipv6 ifdown-sit ifup-aliases ifup-isdn ifup-routes ifup-wireless
ifdown ifdown-isdn ifdown-Team ifup-bnep ifup-plip ifup-sit init.ipv6-global
ifdown-bnep ifdown-post ifdown-TeamPort ifup-eth ifup-plusb ifup-Team network-functions
[root@localhost network-scripts]# vi ifcfg-ens37
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
# 修改
NAME="ens37"
# 修改
UUID="249c0488-7050-345f-9409-af1908186ce4"
# 修改
DEVICE="ens37"
ONBOOT="yes"
# 修改
IPADDR=192.168.1.11
NETMASK=255.255.255.0
# 修改
GATEWAY=192.168.1.2
DNS1=8.8.8.8
DNS2=114.114.114.114
ZONE=public
5.4 重启网络
[root@localhost network-scripts]# systemctl restart network
[root@localhost network-scripts]#
5.5 验证仅主机模式下的IP是否为192.168.1.11
[root@localhost network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:c7:ed:be brd ff:ff:ff:ff:ff:ff
inet 192.168.10.11/24 brd 192.168.10.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::74fc:6ac9:ac81:8fc2/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:50:56:2e:5f:ac brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global noprefixroute ens37
valid_lft forever preferred_lft forever
inet6 fe80::6488:dd1b:9912:7975/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@localhost network-scripts]#
更多推荐
已为社区贡献7条内容
所有评论(0)