目的:通過統(tǒng)一地址實現(xiàn)對外同一地址暴露
1.系統(tǒng)配置文件開啟 ipv4 端口轉(zhuǎn)發(fā)
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
2.查看防火墻配置端口轉(zhuǎn)發(fā)之前的狀態(tài)
firewall-cmd --state
firewall-cmd --list-all
3.開啟 IP 偽裝
firewall-cmd --add-masquerade --zone=public --permanent
firewall-cmd --reload
4.添加端口轉(zhuǎn)發(fā)
firewalld-cmd --permanent --zone=<區(qū)域> --add-forward-port=port=<源端口號>:proto=<協(xié)議>:toport=<目標(biāo)端口號>:toaddr=<目標(biāo)IP地址>
firewall-cmd --add-forward-port=port=8871:proto=tcp:toport=8871:toaddr=172.16.205.4 --zone=public --permanent
5.重新加載防火墻并進(jìn)行測試
firewall-cmd --reload
附:刪除端口轉(zhuǎn)發(fā)文章來源:http://www.zghlxwxcb.cn/news/detail-830422.html
firewall-cmd --remove-forward-port=port=8871:proto=tcp:toport=8871:toaddr=172.16.205.4 --zone=public --permanent
firewall-cmd --reload
firewall-cmd --list-all
刪除 IP 偽裝文章來源地址http://www.zghlxwxcb.cn/news/detail-830422.html
firewall-cmd --remove-masquerade --zone=public --permanent
firewall-cmd --reload
firewall-cmd --list-all
到了這里,關(guān)于linux-firewalld防火墻端口轉(zhuǎn)發(fā)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!