CodexBloom - Programming Q&A Platform

how to to use `iptables` to forward traffic to specific port on CentOS 8 due to connection reset errors

👀 Views: 81 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-07
linux iptables centos bash

I'm trying to set up port forwarding using `iptables` on my CentOS 8 server to redirect traffic from port 8080 to port 80. I configured my iptables rules as follows: ```bash iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80 iptables -A FORWARD -p tcp -d 192.168.1.10 --dport 80 -j ACCEPT ``` After applying these rules, I checked with `iptables -L -v -n` and confirmed the rules were added. However, when I try to access `http://my-server-ip:8080`, I get a connection reset behavior. Additionally, checking the logs with `journalctl -xe` shows several entries like: ``` Feb 25 12:34:56 my-server kernel: DROP IN=eth0 OUT= MAC=... SRC=192.168.1.100 DST=192.168.1.10 LEN=60 TCP SYN RST ... ``` I've also made sure that SELinux is permissive using `setenforce 0`, and I confirmed that nothing else is currently using port 80. I've tried flushing the iptables rules and reapplying them, but the issues continue. Is there something I'm missing, or a specific configuration I should check to ensure the port forwarding works correctly?