Vagrant Box (CentOS/7) with MongoDB(v3.4) 3-nodes cluster including a replica set.
Run in terminal: vagrant up
Connect to main box (mongo1) via ssh: vagrant ssh mongo1
Run the setup script for replica set:
cd /vagrant/
sudo sh ./setup.sh
mongo1.vm.network "forwarded_port", guest: 27017, host: 27017
mongo2.vm.network "forwarded_port", guest: 27017, host: 27018
mongo3.vm.network "forwarded_port", guest: 27017, host: 27019
So you are able to connect to the mongo servers from the host via: 127.0.0.1:27017 for mongo1, 127.0.0.1:27018 for mongo2 and so on.
config = { _id: "mongo-replica-set", members:[
{ _id : 0, host : "192.168.22.10:27017"},
{ _id : 1, host : "192.168.22.20:27017"},
{ _id : 2, host : "192.168.22.30:27017"} ]
};