Vagrant box hosts file entries conflicts

Hi,

I noticed that when adding a new node to replica set m103:27003 for the lab Remove and Re-Add a Node, I have NETWORK issue: Failed to connect to 127.0.1.1:27003!

Checking the /etc/hosts file, I see that the hostname m103 is assigned to both 127.0.1.1 and 192.168.103.100 IP addresses!

In my conf files for the nodes, I have set the bindIp to 192.168.103.100,127.0.0.1, which should map it correctly. But it does not.

I have now commented the line:
#127.0.1.1 m103.mongodb.university m103

Rebooted.

Now I have no error and my replica set response to rs.isMaster() shows the following hosts:
“hosts” : [
“192.168.103.100:27001”,
“192.168.103.100:27002”,
“m103:27003”

So one of the node shows the hostname instead of its IP in case there is an IP reconfiguration for the hostname and the DNS keeps finding the correct machine.

Now I do not have any NETWORK failure to a wrong 127.0.1.1 IP address.

Why did we have this entry in the first place in the /etc/hosts file when the virtual machine was created from vagrant?

This may help.Known issue/BUG

Problem with IP 127.0.1.1