I used the following command to open port 2022 in Ubuntu:
sudo iptables -A INPUT -p tcp --dport 2022 -j ACCEPT
But if I start a web server on port 2022 it is not reachable.
If I run the command to see open ports:
sudo iptables -vnL
The output starts with
Now, ports that show up there like 3000 or 4000 work, but 2022 does not.
What's going on and how can I enable port 2022?
Best Answer
The order matters. Your entry for 2022 in the iptables is behind
DROP
, soDROP
is matched first and yourACCEPT
entry is never reached.You need to Insert instead of Append (
-I
instead of-A
).