How to open a port, say 3389, in iptables to allow incoming traffics to it?Related topicsApr 4, 2018 at 10:22 amanonymouse
There are several cases for this question: ipv4 or ipv6 or both, TCP or UDP or both and which interface?
For simplicity, I give commands to allow all (ipv4 and ipv6, TCP and UDP from all interfaces) using port 3389 as an example. You may choose which ones to be used. For other ports, replace 3389 with the port you want to open.
# allow TCP ipv4 iptables -I INPUT -p tcp --dport 3389 -j ACCEPT # allow UDP ipv4 iptables -I INPUT -p udp --dport 3389 -j ACCEPT # allow TCP ipv6 ip6tables -I INPUT -p tcp --dport 3389 -j ACCEPT # allow UDP ipv6 ip6tables -I INPUT -p udp --dport 3389 -j ACCEPT
Note that the rules are in memory only after these commands and will be lost after Linux reboots. If you would like to make it permanent (take effect after reboot), please check How to make iptables/ip6tables configurations permanent across reboot on CentOS 7 Linux? .Apr 4, 2018 at 10:41 amEric Z MaParticipant