Can you connect to Amazon ElastiСache Redis outside of Amazon?

后端 未结 9 1642
梦谈多话
梦谈多话 2020-12-02 05:56

I\'m able to connect to an ElastiCache Redis instance in a VPC from EC2 instances. But I would like to know if there is a way to connect to

9条回答
  •  半阙折子戏
    2020-12-02 06:44

    Its is not possible to directly access the classic-cluster from a VPC instance. The workaround would be configuring NAT on the classic instance.

    NAT need to have a simple tcp proxy

    YourIP=1.2.3.4
    YourPort=80
    TargetIP=2.3.4.5
    TargetPort=22
    
    iptables -t nat -A PREROUTING --dst $YourIP -p tcp --dport $YourPort -j DNAT \
    --to-destination $TargetIP:$TargetPort
    iptables -t nat -A POSTROUTING -p tcp --dst $TargetIP --dport $TargetPort -j SNAT \
    --to-source $YourIP
    iptables -t nat -A OUTPUT --dst $YourIP -p tcp --dport $YourPort -j DNAT \
    --to-destination $TargetIP:$TargetPort
    

提交回复
热议问题