How to allow only selected IPs to access mongodb v 8.0.4

Hello, I’m having a hard time to allow only selected IP to access my self-managed mongodb replica set. Am using mongodb v 8.0 and I’ve tried many ways and its not work.
For example

net:
  bindIP: 127.0.0.0, 54.5.xx.xx
  port:  27017

also

net:
  bindIP: 127.0.0.0;54.5.xx.xx
  port:  27017

This too

net:
  bindIP: "127.0.0.1, 54.5.xx.xx"
  port:  27017

and

net:
  bindIP: [127.0.0.0, 54.5.xx.xx]
  port:  27017

nothing is working

See https://www.mongodb.com/docs/manual/reference/method/db.createRole/ specifically the role document key authenticationRestrictions which does what you want.

1 Like