Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Set Up a Firewall with iptables

iptables filters packets at a low level. Use it when you need fine control or a host without UFW/FirewallD. Order matters: allow first, then deny.

Steps

  1. Install the tools (Ubuntu/Debian):

    sudo apt update
    sudo apt install -y iptables iptables-persistent
  2. Restrictive default policy, then allow loopback and established traffic:

    sudo iptables -P INPUT DROP
    sudo iptables -P FORWARD DROP
    sudo iptables -A INPUT -i lo -j ACCEPT
    sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  3. Allow SSH, HTTP and HTTPS (change SSH port if needed):

    sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  4. List rules and persist them across reboot:

    sudo iptables -L -n -v
    sudo netfilter-persistent save

Tips

  • If you use UFW, do not edit iptables by hand: UFW owns the chains.
  • Keep an open SSH session while testing; a bad rule locks you out until console/reboot.

ext step

Full traffic control on your server: Deploy your Cloud VPS.

Related guides