0
votes

I have a mongodb 2.2.2 setup on ubuntu 12.04 machine and I need to modify binding_ip list while database is running, without mongo restart. Is there a way to do so? Is it possible to do from pymongo?

p.s. I've actually tried

mongod --config /etc/mongodb.conf --bind_ip 127.0.0.1 31.**

with bind_ip list supplied but it says

Wed Dec 19 17:02:05 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

and I'm not sure if it is not just restarting database.

1
Do you have root access on the machine? What exactly is the use case?kmkaplan
@kmkaplan Yes, I do have root. Use case is pretty simple: some clients are constantly deployed on remote machines and connect to the db. I need to restrict access to db to those clients only.Moonwalker
Sounds as if adding iptables(8) rules could do the trick. Is that an option? My understanding is that your mongodb is currently answering on too many addresses and you want to limit those.kmkaplan
@kmkaplan I think it is. The only problem is I barely know iptables but it is fixable, thank you.Moonwalker

1 Answers

2
votes

Apparently you can do with iptables(8) rules. Then try (with 192.0.2.1 being the IP address you want to receive connections on):

iptables -A INPUT -p tcp -d '!' 192.0.2.1 -p 27017 --m state --state NEW -j REJECT

If you already have iptables rules then you may need a different command. Check the output of iptables -L INPUT.