Hi Folks,
I have a server that listens on port 20001.
I want port 80 to be redirected to port 20001.
I have an amazon linux 2 on an instance and set a redirect rule on it using command:
Code:
sudo iptables \
-t nat \
-A PREROUTING \
-p tcp \
--dport 80 \
-j REDIRECT \
--to-ports 20001
And it works. I can curl both port 80 and port 20001. I can also see it as:
Code:
13 121 5868 REDIRECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 20001
Now on another instance with is debian 12 I run the same command and I have:
Code:
12 0 0 REDIRECT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 20001
Notice that protocol tcp is now shown as number 6!
The rule does not work. I can curl port 20001, but I cannot curl port 80.
On the amazon linux instance (the one which works), I also have docker installed and thus:
Code:
1 3868K 229M DOCKER all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
Can that be related?
Please help. Thanks in advance.