Languages
[Edit]
EN

Linux - iptables redirect port 80 to 8080

6 points
Created by:
Kate_C
20500

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.

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - friendly IT community for everyone.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join