Languages
[Edit]
EN

Linux - iptables redirect port 80 to 8080

6 points
Created by:
Kate_C
2952

Hi, today I would like to show you how to redirect port 80 to 8080 by using iptables command under linux.

In order to do that we need to execute below commands from root user.

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

After executing above commands we should redirect all traffic from port 80 to 8080.

If we want to redirect traffic to any other port we just need to change port 8080 to any other like 8081.

In case you modify port 8080 it is used in both commands.

Hey 👋
Would you like to know what we do?
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.