How to configure an internal network with static IP address for three VMs?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

Hello,
I want to create an internal network for three Fedora Server virtual machines. I selected "Internal Network" in the "Network" section for each virtual machine. What should be the IP value in below commands for VM1 to VM3?

Code: Select all

$ sudo nmcli connection modify "UUID" IPv4.address "IP/24"
$ sudo nmcli connection modify "UUID" IPv4.gateway "IP"
$ sudo nmcli connection modify "UUID" IPv4.dns "IP"
$ sudo nmcli connection modify "UUID" IPv4.method manual
My desired IP address range is "192.168.10.X".

Thank you.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to configure an internal network with static IP address for three VMs?

Post by scottgus1 »

Internal, by default, does not have a DHCP server. See Virtualbox Networks: In Pictures: Internal Network.

So if you did not run the vboxmanage commands to attach a DHCP server to the Internal network, you are free to pick whatever IP addresses you wish, by setting static IP addresses inside the OS's in the VMs.

How to set a static IP address is best web-searched in each OS's help channels, as there are no Virtualbox commands that I know of to set a VM's adapter to a static IP addresses.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

scottgus1 wrote:Internal, by default, does not have a DHCP server. See Virtualbox Networks: In Pictures: Internal Network.

So if you did not run the vboxmanage commands to attach a DHCP server to the Internal network, you are free to pick whatever IP addresses you wish, by setting static IP addresses inside the OS's in the VMs.

How to set a static IP address is best web-searched in each OS's help channels, as there are no Virtualbox commands that I know of to set a VM's adapter to a static IP addresses.
Thank you.
I want to set the static IP address inside my VMs and as you can see, I posted the Fedora Server commands about it. I want to know when I have not any "DHCP" and "DNS" server, then what should be the value of "gateway" and "dns" for each VM?
Can I set "8.8.8.8" as DNS? How about Gateway?
dhkorman
Posts: 14
Joined: 12. Aug 2009, 10:19
Primary OS: Ubuntu 8.04
VBox Version: OSE Debian
Guest OSses: Win XP, Win 7 RC1

Re: How to configure an internal network with static IP address for three VMs?

Post by dhkorman »

Unless one of your machines is running a DNS server you do not need to set the DNS server address - you could just select a spare address on the local subnet, which will not be used as you must then populate the "hosts" file on each virtual machine with the addresses and node names you wish to use.

Your three machines are all connected to a single isolated subnet - so you have no need of a gateway. Each machine will use the ARP protocol to determine the MAC address of other machines on its local subnet (virtual LAN segment).
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

dhkorman wrote:Unless one of your machines is running a DNS server you do not need to set the DNS server address - you could just select a spare address on the local subnet, which will not be used as you must then populate the "hosts" file on each virtual machine with the addresses and node names you wish to use.

Your three machines are all connected to a single isolated subnet - so you have no need of a gateway. Each machine will use the ARP protocol to determine the MAC address of other machines on its local subnet (virtual LAN segment).
Thank you for your guidance.
If I use "8.8.8.8" as DNS address, then can it make any problem?
If one of my VM has the DHCP and DNS services, then the Gateway and DNS address is the IP address of that VM? Or Gateway is the IP address of a system that connected to the Internet directly?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to configure an internal network with static IP address for three VMs?

Post by scottgus1 »

Internal cannot get out of the PC. So you would not be able to see 8.8.8.8 for DNS or any other internet or host-based network services through Internal.

If you included a router service in one of your VMs, and added a Bridged or NAT or NAT Network to the VM, then this VM could be the gateway for the Internal network.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

scottgus1 wrote:Internal cannot get out of the PC. So you would not be able to see 8.8.8.8 for DNS or any other internet or host-based network services through Internal.

If you included a router service in one of your VMs, and added a Bridged or NAT or NAT Network to the VM, then this VM could be the gateway for the Internal network.
Thus, the Gateway computer is a computer that access to the Internet?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to configure an internal network with static IP address for three VMs?

Post by scottgus1 »

That is the usual use of a gateway. However, the "gateway" is merely the passage from a private network behind a NAT router to the public network on the other side. On the private side, a computer could access network services anywhere in the private network's IP addresses, and through the "gateway" it can access the services on the public side.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

scottgus1 wrote:That is the usual use of a gateway. However, the "gateway" is merely the passage from a private network behind a NAT router to the public network on the other side. On the private side, a computer could access network services anywhere in the private network's IP addresses, and through the "gateway" it can access the services on the public side.
Thanks.
On two VMs, I did:

Code: Select all

$ sudo nmcli connection modify "UUID" IPv4.address 192.168.100.X
$ sudo nmcli connection modify "UUID" IPv4.method manual
$ sudo nmcli connection down "UUID"
$ sudo nmcli connection up "UUID"
Then opened /etc/hosts file on all VMs and put the IP addresses and host names of each VMs inside it:

Code: Select all

192.168.100.1 node1.localhost.localdomain node1
192.168.100.2 node2.localhost.localdomain node2
...
Then:

Code: Select all

# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.1  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 fe80::a00:27ff:fef5:e155  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:f5:e1:55  txqueuelen 1000  (Ethernet)
        RX packets 22  bytes 3360 (3.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 4232 (4.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.3.15  netmask 255.255.255.0  broadcast 10.0.3.255
        inet6 fe80::a00:27ff:fe35:92d2  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:35:92:d2  txqueuelen 1000  (Ethernet)
        RX packets 1689  bytes 558532 (545.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1426  bytes 141975 (138.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 21  bytes 2435 (2.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 21  bytes 2435 (2.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
And:

Code: Select all

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.3.2        0.0.0.0         UG    101    0        0 enp0s8
10.0.3.0        0.0.0.0         255.255.255.0   U     101    0        0 enp0s8
But VMs can see each other? I never defined any “Gateway” and “DNS”. As I said, in the VirtualBox, I selected “Internal Network” in the “Network” section for each virtual machine. Need I any DNS or Gateway address?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to configure an internal network with static IP address for three VMs?

Post by scottgus1 »

If two physical computers are connected to each other with just an ethernet cable and nothing else (used to need a crossover cable for this, now the network adapters are self-configuring an d a regular ethernet cable can work too) or with a switch between, then the computers only need each other's IP address to communicate. No gateway or DNS needed:

Just a cable:
PC 1             <----------------------------->      PC 2
static IP address                               static IP address
Unmanaged switch between:
PC 1             <----------> switch <--------->      PC 2
static IP address                               static IP address
Either of the above will work without DNS. Virtualbox's 'Internal' is same as the 'Unmanaged switch between' setup.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

Then why my VMs can't see each other?
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How to configure an internal network with static IP address for three VMs?

Post by hack3rcon »

Hello,
Need I a gateway?
Post Reply