Technical

Firewalld port forwarding

Port forwarding from Linux host to another using FirewallD

-Assuming we want to forward host (10.0.0.10 port 5050) to host (10.0.0.20 port 6060)

-On host (10.0.0.10), check / enable IP forwarding

#to check
sysctl net.ipv4.ip_forward

#if the answer =0 then you have to enable it
echo "net.ipv4.ip_forward = 1"|sudo tee /etc/sysctl.d/99-ipforward.conf

-On host (10.0.0.10) add the following rules

firewall-cmd --zone="public" --add-forward-port=port=5050:proto=tcp:toport=6060:toaddr=10.0.0.20 --permanent

firewall-cmd --zone=public --add-masquerade --permanent

-Now restart Firewalld to apply changes

systemctl restart Firewalld

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA