The oldest security method to secure any server is to disallow it from accepting connections from unknown sources. In MongoDB, this is done in a configuration file with a simple line as follows:
net:
bindIp: <string>
Here, <string> is a comma-separated list of IPs that the MongoDB server will accept connections from.