Skip to main content

Mastering iptables: A Comprehensive Guide to Linux Iptables commands.

iptables Commands: A Comprehensive Guide

Aim :

Learn how to use iptables for configuring the IP packet filter rules on a Linux system.

iptables Commands: A Step-by-Step Guide

iptables is a powerful tool for configuring the Linux kernel firewall, providing packet filtering, network address translation (NAT), and other packet mangling. Follow these steps to use iptables for configuring firewall rules.

Guidance on How to Use:

Prerequisite:

Ensure that your Linux system has iptables installed.

iptables Commands:

  • List all current rules:
    sudo iptables -L
  • Allow incoming traffic on a specific port:
    sudo iptables -A INPUT -p [protocol] --dport [port] -j ACCEPT
    Example: sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT (Allow SSH)
  • Deny incoming traffic on a specific port:
    sudo iptables -A INPUT -p [protocol] --dport [port] -j DROP
    Example: sudo iptables -A INPUT -p udp --dport 53 -j DROP (Deny DNS)
  • Allow outgoing traffic on a specific port:
    sudo iptables -A OUTPUT -p [protocol] --dport [port] -j ACCEPT
    Example: sudo iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT (Allow HTTP)
  • Deny outgoing traffic on a specific port:
    sudo iptables -A OUTPUT -p [protocol] --dport [port] -j DROP
    Example: sudo iptables -A OUTPUT -p udp --dport 123 -j DROP (Deny NTP)
  • Save iptables rules:
    sudo iptables-save > /etc/iptables/rules.v4
  • Restore iptables rules from a file:
    sudo iptables-restore < /etc/iptables/rules.v4

Verification:

Verify the applied iptables rules by listing them:

sudo iptables -L

Written by: A.M.Rinas

Contact: mohomadrinas00@gmail.com

Comments

Popular posts from this blog

Use Katalon Studio in ubuntu

How to Install and Use Katalon Studio for Web Testing Step-by-Step Guide to Installing Katalon Studio Katalon Studio is a powerful tool for automating web, API, and mobile testing. In this guide, we'll walk you through the installation process and show you how to create your first test case for a web application. Step 1: Download Katalon Studio Start by downloading the latest version of Katalon Studio from the official website. Choose the version that suits your operating system. Step 2: Extract and Run the Application Once the download is complete, extract the contents of the downloaded file. Inside the extracted folder, locate the katalon.sh file (for Linux users) and run it to launch Katalon Studio: ./katalon If you're on Windows...

Grafana Installation on Ubuntu using Docker

Grafana Installation on Ubuntu using Docker Aim : Install Grafana OSS (open-source version) on Ubuntu using Docker. Grafana Installation Steps Step 1: Pull and Run the Grafana Container Pull and start the Grafana container: sudo docker run -d -p 3000:3000 --name=grafana grafana/grafana-oss -d : Detaches the container and runs it in the background. -p 3000:3000 : Maps port 3000 on your host machine to port 3000 inside the container, enabling access to Grafana's web interface. --name=grafana : Specifies the name of the container as grafana . Step 2: Access Grafana Once the container is running, access Grafana by opening a web browser and navigating to: http://localhost:3000 If Grafana is running on a remote serv...

Creating a Docker Network for Container Communication

Essential SQL Queries for Database Exploration and Management | By A.M.Rinas How to Create a Docker Network Creating a Docker network allows containers to communicate with each other while isolating them from external traffic. This is particularly useful for managing services that need to interact within a defined network. Follow these steps to create a Docker network: Step 1: Open Your Terminal Access your terminal or command prompt where Docker is installed. Step 2: Create a Docker Network Use the following command to create a new Docker network: docker network create your_network_name Replace your_network_name with a name that makes sense for your application. Step 3: Verify the Network Creation You can verif...