To connect to ApsaraDB for MongoDB over the Internet, it is recommended that you use the public network address. For details, see Obtain Internet URL.
You can also use the mapping method to connect to ApsaraDB for MongoDB from a Windows ECS instance over the Internet. Details are as follows:
Log on to the Windows ECS instance and run the following command in the CLI:
netsh interface portproxy add v4tov4 listenaddress=ECS instance public IP address listenport=3717 connectaddress=Connection address of ApsaraDB for MongoDB connectport=3717
To view all port forwarding rules, run the following command:
netsh interface portproxy show all
Verify the connection.
On the local MongoDB shell, connect to the Windows ECS instance and read or write data. For example, if the IP address of the ECS is 22.214.171.124, run the
telnet 126.96.36.199 3717command.
Now your local PC or server can connect to ApsaraDB for MongoDB through port 3717 of the ECS over the Internet.
- portproxy is provided by Microsoft and is not open-sourced. If you have any questions regarding its usage, see usage instructions of netsh portproxy or consult Microsoft.
- You can also use other methods. For example, use portmap to configure mapping.
- After finishing related operations, you can run
netsh interface portproxy delete v4tov4 listenaddress=ECS public IP address listenport=3717to delete the public network forwarding rule.