端口转发内网redis到公网(firewalld和iptables)

firewall转发

# 检查是否允许伪装ip:

firewall-cmd --query-masquerade

# if return no, allow masquerade

firewall-cmd --add-masquerade --permanent

# add tcp port 36379

firewall-cmd --add-port=36379/tcp --permanent

firewall-cmd --reload

firewall-cmd --list-ports

# add port forword

firewall-cmd --add-forward-port=port=36379:proto=tcp:toaddr=10.1.1.1:toport=6379 --permanent

firewall-cmd --reload

firewall-cmd --list-forward

iptables转发

# CentOS 7 disable firewalld, enable iptables

systemctl stop firewalld

systemctl disable firewalld

yum install iptables-services -y

systemctl enable iptables

# Forward redis to public network

iptables -t nat -A PREROUTING -p tcp --dport 36379 -j DNAT --to-destination 10.1.1.1:6379

iptables -t nat -A POSTROUTING -p tcp -d 10.1.1.1 --dport 6379 -j SNAT --to-source 10.2.2.2

# Restart iptables service

service iptables save

service iptables restart

评论

Popular Posts

常用的国内外延迟测速链接(generate_204)

随身WiFi折腾指南: 解锁、刷机与DIY

静下来学习,放松方式资源推荐

HTTP【袋里】是如何对待HTTPS的?

“菜鸟”程序员和“大神”程序员差距在哪里

eMule eXcalibur 1.85.3 简体中文版(风之痕)

官方部署工具ODT安装Microsoft Office(含Visio和Project)

世界尽头与冷酷仙境 - 村上春树

利用cgroup对docker进行全局资源限制(CPU, 内存, IO读写等限制)

小丸工具箱 - ffmpeg视频转码GUI工具