端口转发内网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个小技巧

Wenger 单肩包

EQSecure 4.0 Beta2_4.28 内置小信极限安防规则Pro终结版

瑞克和莫蒂 Rick and Morty (2013-2019)

《贫穷的本质(修订版)》阿比吉特·班纳 & 埃斯特·迪弗洛

怎样做一个男人