CentOS 7 - Diagnose Why Port Forwarding Doesn't Work

Issues related to configuring your network
Post Reply
eduardolucioac
Posts: 22
Joined: 2017/01/25 12:40:27

CentOS 7 - Diagnose Why Port Forwarding Doesn't Work

Post by eduardolucioac » 2019/12/13 18:48:02

I have a CentOS 7 server running KVM and I'm trying to forwarding a port from port 222 to port 22 of a guest (NAT/virbr0 network).

I'm aware that KVM causes problems for port forwarding with a NAT network (virbr0), as we can see in this thread viewtopic.php?f=50&t=71454&start=10#p300631 . I have used this solution in the past and it worked perfectly. However the problem seems to be another now... I would like help to diagnosing what may be happening right now.

---------------

NOTES:

In theory the commands below should solve the problem (even momentarily)...

Code: Select all

firewall-cmd --permanent --zone=public --direct --add-rule ipv4 filter OUTPUT 0 -d 0.0.0.0/0 -j ACCEPT
firewall-cmd --permanent --zone=public --direct --add-rule ipv4 filter FORWARD 0 -d 0.0.0.0/0 -j ACCEPT
firewall-cmd --permanent --zone=public --direct --add-rule ipv4 filter INPUT 0 -d 0.0.0.0/0 -j ACCEPT
firewall-cmd --permanent --zone=public --direct --add-rule ipv4 nat PREROUTING 0 -d 0.0.0.0/0 -p tcp --dport 222 -j DNAT --to-destination 10.2.0.3:22
firewall-cmd --reload
... or...

Code: Select all

iptables -I OUTPUT -d 0.0.0.0/0 -j ACCEPT
iptables -I FORWARD -d 0.0.0.0/0 -j ACCEPT
iptables -I INPUT -d 0.0.0.0/0 -j ACCEPT
iptables -t nat -I PREROUTING -d 0.0.0.0/0 -p tcp --dport 222 -j DNAT --to-destination 10.2.0.3:22
Thanks! =D

Post Reply

Return to “CentOS 7 - Networking Support”