Page Banner

Opening Port on Iptables

By default iptables is the firewall that is enabled on linux systems. It is very simple to open ports without totally disabling the iptables service. Here are simple steps:

iptables -I INPUT -p tcp --dport <port> -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -p tcp --sport  <port> -m state --state ESTABLISHED -j ACCEPT

Example to open http port – 80:

iptables -I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT