赞
踩
目的:同一局域网,两台主机的虚拟机互通
背景:
家里有两台电脑,一台台式,一台手提。想让他们的虚拟机可以直接通信而不是添加端口
以小米路由器为例,确认ip所在网段
机器信息
台式机 192.168.91.192 —> 虚拟机 192.168.91.130
笔记本 192.168.91.218 —> 虚拟机 192.168.91.10
台式机 192
笔记本 218
vmware配置
注意!!!
之前用的NAT模式,linux的网关是192.168.91.2 ,转为桥接后发现上不了网,可能是冲突了,修改linux的网卡网关为192.168.91.1后重启网卡
systemctl restart network
[root@master-10 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.91.10
PREFIX=24
GATEWAY=192.168.91.1
DNS1=223.5.5.5
----- 以下在笔记本虚拟机操作
尝试ping通
[root@master-10 ~]# ping qq.com #外网
PING qq.com (123.151.137.18) 56(84) bytes of data.
64 bytes from 123.151.137.18 (123.151.137.18): icmp_seq=1 ttl=54 time=40.5 ms
64 bytes from 123.151.137.18 (123.151.137.18): icmp_seq=2 ttl=54 time=39.8 ms
^C
— qq.com ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 39.832/40.215/40.599/0.432 ms
[root@master-10 ~]# ping 192.168.91.192 #台式机
PING 192.168.91.192 (192.168.91.192) 56(84) bytes of data.
64 bytes from 192.168.91.192: icmp_seq=1 ttl=128 time=20.5 ms
^C
— 192.168.91.192 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 20.526/20.526/20.526/0.000 ms
[root@master-10 ~]# ping 192.168.91.130 #台式机的虚拟机
PING 192.168.91.130 (192.168.91.130) 56(84) bytes of data.
64 bytes from 192.168.91.130: icmp_seq=1 ttl=64 time=4.38 ms
64 bytes from 192.168.91.130: icmp_seq=2 ttl=64 time=4.12 ms
再来尝试ssh
[root@master-10 ~]# ssh 192.168.91.130
The authenticity of host ‘192.168.91.130 (192.168.91.130)’ can’t be established.
ECDSA key fingerprint is SHA256:3m2moWByK9XxIo+0+69jUnZICIYHpMB4M5MpftaOOJQ.
ECDSA key fingerprint is MD5:0f:6d:62:37:bc:dd:03:a1:28:6c:c8:59:ad:53:6a:5d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.91.130’ (ECDSA) to the list of known hosts.
root@192.168.91.130’s password:
Last login: Fri May 20 23:59:54 2022 from 192.168.91.192
[root@temple-130 ~]# ip a | grep 130
inet 192.168.91.130/24 brd 192.168.91.255 scope global noprefixroute ens33
inet 172.16.1.130/24 brd 172.16.1.255 scope global noprefixroute ens36
ok!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。