Search Our Database

How to Open Ports in iptables

Last updated on |
by

1. SSH to your server

2. Enter the following commands to open the port in iptables (in this case, we are opening port 25).

# iptables -I INPUT -p tcp --dport 25 -j ACCEPT
The command above is for opening the incoming port.
# iptables -I OUTPUT -p tcp --sport 25 -j ACCEPT
The command above is for opening the outgoing port.

3. To make the changes persistent after a reboot, edit /etc/rc.local and append the two iptables commands at the end of the file.