Jump to content

Quickly Allowing/Denying IP’s Using Iptables


Recommended Posts

How do you block an IP using iptables?

iptables -A INPUT -s xx.xx.xx.xx -j DROP

How do you block an IP from a specific port?

iptables -A INPUT -p tcp -s xx.xx.xx.xx --dport PORT -j DROP
(xx.xx.xx.xx is the remote IP address and PORT is the port number you wish to allow/deny access to.)

How do you allow access to an IP?

iptables -A INPUT -s xx.xx.xx.xx -j ACCEPT

How do you allow access to an IP to a specific port using iptables?

iptables -A INPUT -p tcp -s xx.xx.xx.xx --dport PORT -j ACCEPT

(Again, xx.xx.xx.xx is the remote IP address and PORT is the port number you wish to allow/deny access to.)

How do you block a scanner on a server for example "blablabla.at.ISC.SANS" using iptables?

iptables -I INPUT -p tcp --dport 80 -m string --algo bm \
--string 'GET /blablabla.at.ISC.SANS.' -j DROP

More information can be found in our article about the most common iptables rules:
https://www.lcwhost.org/topic/21-basic-and-most-common-iptables-rules/

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...