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:  TUXEDO InfinityBook Pro 16 Gen 8 Full Specs | Pre-Order Now
Linux

Post navigation

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

Related Posts

How To Remove Files And Directories In Linux [Examples] How To Remove Files And Directories In Linux [Examples] Linux
List Of Best Linux FTP Client In 2018 Linux
AV Linux MX-21 Multimedia Production Distro Released AV Linux MX-21 Multimedia Production Distro Released Linux
NetworkManager text user interface (TUI) tool, nmtui, provides a text interface to configure networking by controlling NetworkManager. 50 Useful Linux Networking Commands And Tools Linux
Examples of Touch Command in Linux What Is A Touch Command: Examples of Touch Command in Linux Linux
Useful & Best Free Linux Logfile Viewers Useful & Best Free Linux Logfile Viewers 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 Engineer, Global IT Business Intelligence

    • Collierville, TN (Remote)
    • The Juice Plus+ Company
    • Full Time
  • Grant Writer and Institutional Giving Liaison

    • San Leandro, CA
    • Boys & Girls Clubs of San Leandro
    • Full Time
  • Technical Writer

    • North Haven, CT
    • Insight Global
    • Full Time
  • Customs Brokerage Entry Writer

    • Chicago, IL
    • ALS Recruiting Ltd
    • Full Time
  • Service Writer

    • Elmhurst, IL
    • IN DEMAND Recruitment & Consulting Inc.
    • Full Time
  • Customs Broker – Entry Writer

    • Schaumburg, IL
    • LaSalle Network
    • Full Time
  • Technical Writer

    • Atlanta, GA
    • Visionaire Partners
    • Full Time
  • Specification Writer

    • Montgomery, AL
    • PANGEATWO
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme