ubuntu iptables open port
Solution 1
Make sure that the corresponding iptables-load
is running on boot.
[Edit]
Oh. See in your netstat output the 127.0.0.1:8001
? That means the program is only listening on localhost. The firewall isn't at fault here. You need to frob the program's config into listening on your IP, or even better on every interface.
Solution 2
After running the rules you want to save within your iptables you can run the command:
iptables-save
OR
iptables-save > /etc/iptables.rules
which will save the rules to your current rules file if you have'nt changed it from the default.
You should also take a look at How To - Saving iptables from the ubunu wiki.
Weiwei
Updated on September 17, 2022Comments
-
Weiwei almost 2 years
i have run this command
'iptables -A INPUT -p tcp -m tcp --dport 8001 -j ACCEPT'
how do I apply this rule permanantly? i did run 'iptables-save', but it seemed not working
Thanks a lot
I have this from 'netstat -an'
tcp 0 0 127.0.0.1:8001 0.0.0.0:* LISTEN 2021/ppstream
and this by 'iptables -L '
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:8001 Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
but i still can not connect to this port, i am totally lost.
-
Weiwei almost 14 yearsthanks, i did iptables-save but i could not connect to this port from other computer, something else i need to look into?
-
Guapo almost 14 yearswell i dont know what you want to do but usually it would be
sudo iptables -A INPUT -p tcp --dport 8001 -j ACCEPT
to simple allow connections to port 8001 but since i dont know what other rules you have, you can possible have another rule that may be affecting this one. -
Weiwei almost 14 yearsThanks a lot, that(program config) was the problem. It is good now!