Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
Simple IPtables Rules For Linux Administrator

Simple IPtables Rules For Linux Administrator

Posted on December 11, 2019 By admin No Comments on Simple IPtables Rules For Linux Administrator

Insight: Simple IPtables Rules For Linux Administrator

In this post, we are going to talk on basic but useful Linux commands related to IPtables.

List Of Simple IPtables Rules For Linux Administrator

 

Check the Current Rules

Run the following command to check the current rules.

$ sudo iptables -L

Check the Default Policy Chain Behavior

Run the following command to print out the default policy chain behavior of your system.

$ sudo iptables -L | grep policy

Check Iptables Status

Run the following command to see the current status of your iptables

$ sudo iptables -L -v

List Rules by Specification

It will display a list of all your rules based on their specifications.

$ sudo iptables -S

Reset Iptables Rules

Run the following command to reset Iptables rules.

$ sudo iptables -F

Starting the Iptables Firewall

Run the following command to start Iptables firewall where systemd is used.

$ sudo systemctl start iptables
Systems that use sysvinit

$ sudo /etc/init.d/iptables start

Flush Iptables and Persist Changes

For flushing iptables and make the changes permanent.

$ sudo iptables -F && sudo /sbin/iptables-save

Saving Modified Iptables

$ sudo service iptables save

Stopping the Iptables Firewall

For systems that use systemd.

$ sudo systemctl stop iptables

For systems running sysvinit.

$ sudo /etc/init.d/iptables stop

Restarting the Iptables Firewall

Run the following command in your Linux to restart the Iptables firewall.

$ sudo systemctl restart iptables

Check All Existing Rules

Run the following command to print out the existing Iptables firewall rules in your system.

$ sudo iptables -L -n -v

Check Existing Rules for Specific Tables

Run the following command to check existing rules for the specific tables.

$ sudo iptables -t nat -L -v -n

List Rules for TCP Chains Only

Run the following  command in Linux to list rules for TCP chains.

$ sudo iptables -S TCP

List Rules for UDP Chains Only

For UDP chains rules.

$ sudo iptables -S UDP

Block all Incoming Requests

Run the following command to block all incoming requests.

$ sudo iptables INPUT -j DROP

Block a Specific IP Address

Run the following command to block a specific IP address.

$ sudo iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP

Block all TCP requests from an IP

Run the following command to block all TCP requests from an IP.

$ sudo iptables -A INPUT -p tcp -s xxx.xxx.xxx.xxx -j DROP

Unblock an IP Address

Run the following command to unbloack an IP address in Linux.

$ sudo iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP

Block IP Address Ranges

The below command lets you block all incoming requests from the IP range xxx.xxx.xxx.0/24.

$ sudo iptables -A INPUT -s xxx.xxx.xxx.0/24 -j DROP

Unblock IP Address Ranges

For unblocking a given IP address range from your iptables firewall.

$ sudo iptables -D INPUT -s xxx.xxx.xxx.0/24 -j DROP

Block all TCP requests for Given IP Range

Command to block all TCP requests from a given IP range, say xxx.xxx.xxx.0/24.

$ sudo iptables -A INPUT -p tcp -s xxx.xxx.xxx.0/24 -j DROP

Unblock all TCP requests for Given IP Range

Run the following command to unblock all TCP requests for given IP range.

sudo iptables -D INPUT -p tcp -s xxx.xxx.xxx.0/24 -j DROP

Block TCP Connections on Specific Ports

Block a specific port. For example, we are blocking 256 in this case.

$ sudo iptables -A OUTPUT -p tcp --dport 256 -j DROP

Allow TCP Connections on Port 80

Run the command to allow TCP connections on port 80.

$ sudo iptables -A INPUT -p tcp -s xxx.xxx.xxx.0/24 --dport 80 -j ACCEPT

Reject TCP Connections on Port 80

$ sudo iptables -A INPUT -p tcp -s xxx.xxx.xxx.0/24 --dport 80 -j DROP
READ More Relevant Stuff:  Deepin 20.5 Released With New Features & Improvements
Linux

Post navigation

Previous Post: Install OBS In Linux Operating System [2023]
Next Post: Install PuTTY On Linux: Beginner’s Guide

Related Posts

CutiePi: Ultra-Portable, Open-Source Raspberry Pi Tablet CutiePi: Ultra-Portable, Open-Source Raspberry Pi Tablet Linux
NES Emulators In Linux Best NES Emulators In Linux: Play Old NES Games in Linux [2023] Linux
List Of Linux Benchmark Tools List Of Linux Benchmark Tools Linux
How To Install Microsoft Office On Linux 2023 How To Install Microsoft Office On Linux 2023 How To Ubuntu
How To Use SCP Command To Securely Transfer Files How To Use SCP Command To Securely Transfer Files [2023] How To Ubuntu
Top 10 Best Linux Password Managers In 2019 Top 10 Best Linux Password Managers In 2020 Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023
  • Linux Wget Examples September 27, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
  • Search Jobs
  • Post a Job
  • Job Dashboard
  • Contact Us
  • About US
  • Cookie Policy
  • Terms and Conditions
  • Privacy Policy
  • Sitemap
  • Write For US

Tags

android apps centos ChatGPT command Commands Debian deepin Desktop docker Fedora fix game games Gaming gnome google kernel linux linux commands linux kernel Linux laptops Linux Mint Linux themes minecraft NVIDIA Python Raspberry Pi sysadmin themes ubuntu ubuntu 18.04 Ubuntu 18.04 LTS Ubuntu 20.04 ubuntu 20.04 lts Ubuntu 22.04 LTS Ubuntu games Ubuntu kernel ubuntu themes ubuntu tutorial VirtualBox Windows Windows 11 Wine WSL
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at [email protected]
  • Data Scientist – Systematic Trading

    • Miami-Dade County, FL (Remote)
    • Selby Jennings
    • Full Time
  • Biopharmaceutical Technical Writer

    • Albany, NY
    • Trinity Consultants - Advent Engineering
    • Full Time
  • Executive Assistant (artificial intelligence (AI) tools)

    • Newark, NJ
    • Stratford Solutions Inc.
    • Full Time
  • User Experience Writer

    • Canada
    • Creative Niche
    • Full Time
  • Senior Grant Writer

    • Washington DC
    • UNITED NEGRO COLLEGE FUND
    • Full Time
  • Senior Negotiator & Demand Writer

    • Costa Mesa, CA
    • The Law Offices of Daniel Kim
    • Full Time
  • Technical Writer

    • Branchburg, NJ
    • Process Alliance
    • Full Time
  • Technical Writer – Integrations (Tempus)

    • Pittsburgh, PA
    • PNC Financial Services Group
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme