- Most Linux distributions come with a kernel that supports net filters, the network filter API on top of which IPTables is built. We will install UFW, a set of tools that help simplify IPTables configuration:
apt-get install ufw
- Enable the UFW service:
ufw enable
- Add the firewall rules to allow all traffic on port 27017 from known IPs:
ufw allow from 10.1.1.1 to any port 27017ufw allow from 10.1.1.2 to any port 27017ufw allow from 10.1.1.3 to any port 27017
- Deny all other incoming requests to port 27017:
ufw deny from any to any port 27017
- Check the firewall rules:
ufw status numbered
- You should see an output similar to this: