>假设我在服务器上运行一个 mongodb 实例,该实例的公共 IP 地址"120.*.*.*
"。出于安全目的,我希望仅允许来自具有公共IP"40.*.*.*"
和"12.*.*.*
"的服务器的传入连接。有什么方法可以实现这一点。
opt 1( mongodb 3.6:
use admin
db.createUser(
{
user: "restricted",
pwd: "password",
roles: [ { role: "readWrite", db: "reporting } ],
authenticationRestrictions: [ {
clientSource: ["40.0.0.0","12.0.0.0"],
serverAddress: ["120.0.0.0"]
} ]
}
)
选项 2(通过操作系统防火墙