端口转发内网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

为什么你睡了11个小时仍然觉得疲累?

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

《凯恩与林奇2:伏天》原版+硬盘版

《钢铁是怎样炼成的》奥斯特洛夫斯基

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

使用 Nginx 状态码 444 提升 HTTPS 服务安全性,屏蔽 HTTP 497 访问提示

起动战士XP(Ultimate Knight Windom XP) 2.008 简体中文版

让你一生都受用的85句话 (适合做QQ签名)

在金融行业工作的优势

WinRAR 7.13 官方简体中文无广告版