Created
May 7, 2024 08:28
-
-
Save bayramlcm/ae2d0234517c5c6e58b5da130bc9d359 to your computer and use it in GitHub Desktop.
RHEL Port Forward
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PORT Forward Create | |
sudo iptables -t nat -A PREROUTING -p tcp --dport {PORT} -j DNAT --to-destination {HOST} | |
sudo iptables -t nat -A POSTROUTING -j MASQUERADE | |
sudo sysctl -w net.ipv4.ip_forward=1 | |
sudo firewall-cmd --zone=public --add-port={PUBLIC_PORT}/tcp --permanent | |
sudo firewall-cmd --reload | |
# PORT Forward Delete | |
sudo iptables -t nat -F | |
sudo sysctl -w net.ipv4.ip_forward=0 | |
sudo firewall-cmd --zone=public --remove-port={PUBLIC_PORT}/tcp --permanent | |
sudo firewall-cmd --reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment