In this recipe, we will take a quick look at how to use Linux IPTables to add firewall rules that can restrict unwanted access to MongoDB processes.
Restricting network access using firewalls
Getting ready
You need standard MongoDB binaries on a Linux operating system. We are going to use Uncomplicated Firewall (UFW) tools, which is a handy wrapper built on top of IPTables. We assume that you have a three-node replica set running on the following hosts:
Hostname |
IP |
server1.foo.com |
10.1.1.1 |
server2.foo.com |
10.1.1.2 |
server3.foo.com |
10.1.1.3 |