How to use AWS ElasticCache on Azure

Standard
[ec2-user@ip-174-129-100-10 ~]$ cat /etc/rc.local
echo "redis-name";
ADDRESS=`nslookup redis-name.7exo1h.0001.use1.cache.amazonaws.com | grep "Address:" | tail -n 1 | awk '{print $2}'`;
echo $ADDRESS;
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 26379 -j DNAT --to-destination $ADDRESS:6379;
iptables -t nat -A POSTROUTING -j MASQUERADE;
sysctl net.ipv4.ip_forward=1;
 
[ec2-user@ip-174-129-100-10 ~]$ iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
DNAT       tcp  --  anywhere             anywhere             tcp dpt:26379 to:10.153.181.100:6379
 
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
 
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  anywhere             anywhere
azure@azure:/home/azure# cat /etc/rc.local
# redis-name
iptables -t nat -I OUTPUT -p tcp -d redis-name.7exo1h.0001.use1.cache.amazonaws.com --dport 6379  -j DNAT --to-destination 174.129.100.10:26379
 
azure@azure:/home/azure# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
 
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DNAT       tcp  --  anywhere             ec2-50-17-68-100.compute-1.amazonaws.com  tcp dpt:6379 to:174.129.100.10:26379
 
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.