bindIp: 127.0.0.1bindIp: 127.0.0.1,169.254.x.ybindIp: 127.0.0.1,hostname.localbindIp: hostname.localHi Ved,
As you can see, it appears as whenever I use hostname.local, mongo also binds to the public ip.
Have you found out what’s causing your network issues?
I have tried to reproduce the issue you’re seeing but have been unsuccessful so far. I ran a basic mongod as:
mongod --port 27017 --bind_ip 127.0.0.1,xyz.local
where xyz.local is the name of my local machine, bound to a local address. The output of netstat shows:
$ netstat -an | grep 27017
tcp4 0 0 10.x.x.xxx.27017 *.* LISTEN
tcp4 0 0 127.0.0.1.27017 *.* LISTEN
where I can see that mongod binds to the exact two IPs I have provided (xyz.local maps to 10.x.x.xxx).
If you’re still having this issue, could you please post:
db.serverCmdLineOpts()/etc/hosts fileBest regards,
Kevin
db.serverCmdLineOpts()
{
"argv" : [
"/usr/bin/mongod",
"--config",
"/etc/mongod.conf"
],
"parsed" : {
"config" : "/etc/mongod.conf",
"net" : {
"bindIp" : "127.0.0.1,app.local",
"port" : 27017
},
"processManagement" : {
"timeZoneInfo" : "/usr/share/zoneinfo"
},
"storage" : {
"dbPath" : "/var/lib/mongodb",
"journal" : {
"enabled" : true
}
},
"systemLog" : {
"destination" : "file",
"logAppend" : true,
"path" : "/var/log/mongodb/mongod.log"
}
},
"ok" : 1
}# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,app.local
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:127.0.0.1 localhost
a.b.c.d app.mydomain.com apptcp 0 0 a.b.c.d:27017 0.0.0.0:* LISTEN
tcp 0 0 169.254.69.130:27017 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTENHi,
First of all please note that from what you described, this is a network setup issue and not a MongoDB issue.
Having said that, I would presume that the unexpected binding you see is due to the app.local name binding to the IP address you did not expect it to. You can check if this is the case by trying to ping app.local from itself, and see what IP address it resolves to.
Since a database server is primarily a static resource, it’s best to assign a static IP address to important machines in your network (e.g. the machine running mongod), and instruct mongod to bind to that static address. This way, your application can just use the static address, aliased with a readable name in their own /etc/hosts if so desired.
Another point for using a static IP is that MongoDB does not auto-refresh the IP it’s binding to. So if for some reason the IP it binds to changes (since you’re binding it to the name), then MongoDB would not be aware of this and as a result needs to be restarted.
For the best response regarding network issues, I would recommend you to ask a question in a network-related forum such as ServerFault.
Best regards,
Kevin
First of all please note that from what you described, this is a network setup issue and not a MongoDB issue.
Having said that, I would presume that the unexpected binding you see is due to the
app.localname binding to the IP address you did not expect it to. You can check if this is the case by trying toping app.localfrom itself, and see what IP address it resolves to.
Since a database server is primarily a static resource, it’s best to assign a static IP address to important machines in your network (e.g. the machine running
mongod), and instructmongodto bind to that static address. This way, your application can just use the static address, aliased with a readable name in their own/etc/hostsif so desired.Another point for using a static IP is that MongoDB does not auto-refresh the IP it’s binding to. So if for some reason the IP it binds to changes (since you’re binding it to the name), then MongoDB would not be aware of this and as a result needs to be restarted.
For the best response regarding network issues, I would recommend you to ask a question in a network-related forum such as ServerFault.