Skip to content

Instantly share code, notes, and snippets.

@bayramlcm
Created May 7, 2024 08:28
Show Gist options
  • Save bayramlcm/ae2d0234517c5c6e58b5da130bc9d359 to your computer and use it in GitHub Desktop.
Save bayramlcm/ae2d0234517c5c6e58b5da130bc9d359 to your computer and use it in GitHub Desktop.
RHEL Port Forward
# 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