Reputation: 105
I have a virtual machine attached to NAT. It has the default IP 10.0.2.15. Now I create another machine but the new machine still has the same IP address 10.0.2.15. Is there a way that I can keep the network setting for the first machine, change the second machine's IP to something like 10.0.3.15 and make those two machine able to ping to each other (as in a LAN network) ?
Upvotes: 2
Views: 28119
Reputation: 480
Use NAT Network
instead of NAT
.
This worked for me with VirtualBox version 5.2.22 and Redhat/Ubuntu. The VM's had different IP's and both had access to internet.
For, both VM's :
Nat Network
in attached to
select Allow VMs
in Promiscuous mode
(advanced chevron)ifconfig
(or ip addr
) command to find out each VM IP. In my case : 10.0.2.4 and 10.0.2.5The following table provides an overview of the most important networking modes:
| | VM <-> Host | VM1 <-> VM2 | VM -> Internet | VM <- Internet |
|----------|-------------|-------------|----------------|----------------|
| HostOnly | Yes | Yes | No | No |
| Internal | No | Yes | No | No |
| Bridged | Yes | Yes | Yes | Yes |
| NAT | No | No | Yes | Port forward |
| NATNet | No | Yes | Yes | Port forward |
NB: If you want to connect to the VMs with tty, you need to do ip forwarding.
In the Virtualbox config:
File
-> Preference
-> Network
-> double-clic Natnetwork
-> port fordwarding
-> add a rule : host ip 127.0.0.1
, port 23
(or whatever to put in tty), Guest IP (the VM ip, example: 10.0.2.5
), guest port 22
Upvotes: 8
Reputation: 1725
You cant do that one. You should use different networking type to connect two virtual machines. I suggest you to use internal networking/bridged networking.
Ref: http://trainenv.blogspot.in/2016/03/virtual-networking.html
Upvotes: 1