SysTutorials Forums QA How to open a port in iptables?

How to open a port, say 3389, in iptables to allow incoming traffics to it?

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? .

Reply To: How to open a port in iptables?
Your information:

<a href="" title="" rel="" target=""> <blockquote cite=""> <code> <pre> <em> <strong> <del datetime=""> <ul> <ol start=""> <li> <img src="" border="" alt="" height="" width="">

Please share if you like this post: