Article 6J868 IPTables redirect rule works on amazon linux, not on debian

IPTables redirect rule works on amazon linux, not on debian

by
ario
from LinuxQuestions.org on (#6J868)
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 20001And 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 20001Notice 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 LOCALCan that be related?
Please help. Thanks in advance.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments