On this page本页内容
Starting in MongoDB 3.6, MongoDB binaries, 从MongoDB 3.6开始,MongoDB二进制文件,mongod
and mongos
, bind to localhost by default.mongod
和mongos
默认绑定到localhost
。If the 如果net.ipv6
configuration file setting or the --ipv6
command line option is set for the binary, the binary additionally binds to the localhost IPv6 address.net.ipv6
如果为二进制文件设置了配置文件设置或--ipv6
命令行选项,则二进制文件还绑定到localhost IPv6地址。
Warning
Make sure that your 确保mongod
and mongos
instances are only accessible on trusted networks.mongod
和mongos
实例只能在受信任的网络上访问。If your system has more than one network interface, bind MongoDB programs to the private or internal network interface.如果您的系统有多个网络接口,请将MongoDB程序绑定到专用或内部网络接口。
To override and bind to other ip addresses, you can use the 要覆盖并绑定到其他ip地址,可以使用net.bindIp
configuration file setting or the --bind_ip
command-line option to specify a list of hostnames or ip addresses.net.bindIp
文件配置文件设置或--bind_ip
命令行选项来指定主机名或ip地址的列表。
Warning
Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access.在绑定到非本地主机(例如,公共访问)IP地址之前,请确保已保护集群不受未经授权的访问。For a complete list of security recommendations, see Security Checklist.有关安全建议的完整列表,请参阅安全性检查列表。At minimum, consider enabling authentication and hardening network infrastructure.至少,请考虑启用身份验证和强化网络基础设施。
For example, the following 例如,以下mongod
instance binds to both the localhost and the hostname My-Example-Associated-Hostname
, which is associated with the ip address 198.51.100.1
:mongod
实例绑定到localhost
和主机名My-Example-Associated-Hostname
,后者与ip地址198.51.100.1
关联:
In order to connect to this instance, remote clients must specify the hostname or its associated ip address 为了连接到此实例,远程客户端必须指定主机名或其关联的ip地址198.51.100.1
:198.51.100.1
:
To bind to all IPv4 addresses, you can specify the bind ip address of 要绑定到所有IPv4地址,可以将绑定ip地址指定为0.0.0.0
.0.0.0.0
。To bind to all IPv4 and IPv6 addresses, you can specify the bind ip address of 要绑定到所有IPv4和IPv6地址,可以指定绑定ip地址::,0.0.0.0
or alternatively, use the new net.bindIpAll
setting or the new command-line option --bind_ip_all
.::,0.0.0.0
,或者使用新的net.bindIpAll
设置或新的命令行选项--bind_ip_all
。
See also另请参阅