问题原文
原帖链接 · matiu · CC BY-SA 3.0
I run ssh on port 5678.
For my source IP address 1.2.3.4 - I want to connect on port 22 and have firewalld port forward to 5687.
No other source IP addresses get port forwarding.
What firewall-cmd line would I type to achieve this ?
已采纳解答
原帖链接 · matiu · CC BY-SA 4.0
Figured it out:
CUSTOMPORT=$(netstat -tlpn | grep 0.0.0.0.*ssh | cut -d: -f2 | cut -f1 -d\ )
SOURCE_IP=1.2.3.4
firewall-cmd --zone=public --permanent --query-masquerade
firewall-cmd --zone=public --permanent --add-masquerade
firewall-cmd --zone=public --permanent --add-rich-rule="rule family=\"ipv4\" source address=\"${SOURCE_IP}\" forward-port port=\"22\" protocol=\"tcp\" to-port=\"${CUSTOMPORT}\""
firewall-cmd --reload
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
