第0步驟: 開啟轉發生效
[root@node178.oldboy.com ~]# cat /proc/sys/net/ipv4/ip_forward
1
[root@node178.oldboy.com ~]# tail /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
# 開啟 NAT 轉發
firewall-cmd --permanent --zone=public --add-masquerade
# 開放 端口
firewall-cmd --zone=public --add-port=50070/tcp --permanent
# 檢查是否允許 NAT 轉發 firewall-cmd --query-masquerade
# 禁止防火牆 NAT 轉發 firewall-cmd --remove-masquerade
第一步: 查看激活的zones ens192外網 ens224內網網卡的綁定
[root@node178.oldboy.com ~]# firewall-cmd --get-active-zones
internal
interfaces: ens224
public
interfaces: ens192
第二步: 開放50070端口:
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" port protocol="tcp" port="50070" accept"
firewall-cmd --reload
第三步 : 設置轉發 將zone public 網卡的 端口50070轉發到端口50070 地址是 172.16.10.178
[root@node178.oldboy.com ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=50070:proto=tcp:toport=50070:toaddr=172.16.10.178
success
firewall-cmd --permanent --zone=public --add-forward-port=port=50070:proto=tcp:toport=50070:toaddr=172.16.10.178
生效reload
firewall-cmd --reload
