Submit a Ticket
Support Center » Knowledgebase » Virtual Private Servers (VPS) & Cloud » Opening ports via iptables

Opening ports via iptables

1. Connect to your Linux VPS/Cloud via SSH.

2. List the current IPtables rules using the following command:

# iptables -L

  • You should receive a similar output:

Chain INPUT (policy ACCEPT) target prot opt source destination

Chain FORWARD (policy ACCEPT) target prot opt source destination

Chain OUTPUT (policy ACCEPT) target prot opt source destination

3. The first firewall rule you need to add is the following one:

# iptables -A INPUT -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT

NOTE: This tells your Firewall to accept your current SSH connection.

4. The next step is to allow traffic on your loopback interface and to open some basic ports:

# iptables -A INPUT -i lo -j ACCEPT

# iptables -A OUTPUT -o lo -j ACCEPT

# iptables -A INPUT -p tcp –dport 25 -j ACCEPT

# iptables -A INPUT -p tcp –dport 80 -j ACCEPT

5. You are now ready to open the other ports you want to allow traffic to. Use the same command as you used to open the port 25 and 80 in the previous example.

 This answer was helpful  This answer was not helpful