How to configure an internal network for three VMs?

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

$ 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.

Any idea?
I don’t know when I have not any DHCP and DNS server, then what should be the value of “gateway” and “dns”?

You can have it more beautiful:

10.0.0.10 .20 .30 for the VM’s
10.0.0.1 the gateway or let it empty if you don’t want to make a router vm.
1.0.0.1 the DNS if you have access to the internet.

If you just want to resolve the subnet you could make it in the host file of one of this 3 VM’s and use it as DNS.

Now it comes the best … if you want to ping / traceroute you just can use:
ping 10.10
ping 10.1
ping 1.1

:slightly_smiling_face:

1 Like

Thank you.
Thus, a gateway is not mandatory for my VMs? I guess the gateway is needed when I have a DHCP server and the gateway is the IP address of my DHCP server. AM I right?

Servers normally use a static IP-Address (Fix IP). There is no need for DHCP (Dinamic IP).

As you said you want all servers in the sub net of 192.168.10.x/24 you have .1 to .254 addresses who are communicating within this sub net. .0 is the address of the network and .255 is the broadcast address.

If your DHCP server is a router who is used to connect to the internet, yes then you can use the ip as a default gateway. Just if your router is in an other sub net like 192.168.11.x/24 you have to create a route between this two networks.

Anyway, if this environment is build up on your working place, you better talk with your network department :wink:

1 Like

Thanks.
When I selected “Internal Network” in the VirtualBox, then no need for a gateway and DNS. AM I right?

Yes and no. Gateway you don’t need.

If you want to resolve DNS like names like:

webserver  192.168.10.10
mailserver  192.168.10.20
db-server   192.168.10.30

you can put this in lets say in the webserver’s /etc/hosts file. Now you can use it as a DNS like 192.168.10.10 to resolve within your virtualbox images.

If I’m not wrong you should be able just to add the computers and servers from the network 192.168.10.0/24 to one hostfile (from the webserver {in my example}) and a name resolution should be possible.

If all your computers have the avahi-daemon.service - Avahi mDNS/DNS-SD Stack active, you can also skip the DNS part. Avahi resolves over the hostname you give while installing fedora.

1 Like

Thank you.
What is the main usage of “/etc/hosts” file? When I put the host names and IP addresses of each VM inside of this file on all VMs, then they can see each other.

The /etc/hosts file is not really a replacement for a DNS. It is just a workaround to resolve the localhost while configuring your system.

But as you see it can be used to resolve names in a local network. It is just not really convenient to manage. And it is not made for this purpose.

If you really like 0 config look that you have avahi running.

systemctl status avahi-daemon

1 Like

Thanks.
I did below commands on all VMs:

$ 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:

192.168.100.1 node1.localhost.localdomain node1
192.168.100.2 node2.localhost.localdomain node2
...

Then:

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:

# 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.

# systemctl status avahi-daemon
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/usr/lib/systemd/system/avahi-daemon.service; enabled; ven>
     Active: active (running) since Fri 2021-03-19 11:37:46 +0330; 4min 4s ago
TriggeredBy: ● avahi-daemon.socket
   Main PID: 1153 (avahi-daemon)
     Status: "avahi-daemon 0.8 starting up."
      Tasks: 2 (limit: 1119)
     Memory: 1020.0K
        CPU: 21ms
     CGroup: /system.slice/avahi-daemon.service
             ├─1153 avahi-daemon: running [node1.local]
             └─1154 avahi-daemon: chroot helper

Hello,
Which part of my configuration is wrong? In Windows OS, this is easy done: https://www.youtube.com/watch?v=04pAiANkr_s

netmask is /24 alias 255.255.255.0

You might have to make it so:

sudo nmcli connection modify "UUID" IPv4.address 192.168.100.X/24

so you are adding the netmask with the IP address.

Use the network manager applet instead … it is like windows:

As mentioned early … no DNS and no Gateway needed. On the picture is my config as I use it.

1 Like