Overview
TencentDB for Redis® supports public network access in Chengdu, Beijing, Shanghai, and Guangzhou regions. To use public network access in other regions, you can use a CVM instance with a public IP for port forwarding to access TencentDB for Redis® over the public network.
Note:
Because iptables-based forwarding may be unstable, we recommend that you do not access instances over the public network in the production environment.
Directions
Note:
The CVM and TencentDB instances must be under the same account and in the same VPC in the same region, or both in the classic network.
echo 1 > /proc/sys/net/ipv4/ip_forward
2. Configure the forwarding rule. The sample code below forwards access requests originally to 26.xx.x.2:10001
(CVM instance public address with a custom port as desired) to the TencentDB for Redis® instance with the private address 10.0.0.5:6379
:
iptables -t nat -A PREROUTING -p tcp --dport 10001 -j DNAT --to-destination 10.0.0.5:6379
iptables -t nat -A POSTROUTING -d 10.0.0.5 -p tcp --dport 6379 -j MASQUERADE
3. Configure the security group to open the public port of the CVM instance. We recommend that you configure a security group rule to allow only the source which needs to connect to the Redis instance. For more information, see Adding Security Group Rules. 5. After connecting to the TencentDB for Redis® instance, run the info
command. If the database information is returned, the connection is successful.
Was this page helpful?