R-Ts NetWorks

Server the Best

IPtables


IPtables:

 
Exact meaning of an option which are used in iptable command:


A – All source
I – INPUT
s – Source
j – jump on

Procedure:

For Example: If you want to check IP 49.248.23.83 is blocked or not then fire command


iptables -nL | grep 49.248.23.83

You can see the result as below

DROP all — 49.248.23.83 0.0.0.0/0
DROP all — 0.0.0.0/0 49.248.23.83
 
Which means IP is blocked

To unblock that IP address use following command:


iptables -I INPUT -s 49.248.23.83 -j ACCEPT
 
To Block back an IP Address:
 
iptables -A INPUT -d 49.248.23.83 -j DROP

After adding or removing ips from iptables you need to save iptable rule using following command.
service iptables save
 
service iptables restart
 
To allow PORT in iptables you have to follow below commands

Exact meaning of an options which uses in the command
=====================================
p – protocol

dport – destination port
j – jump on
=====================================

iptables -I INPUT -p tcp –dport 2082 -j ACCEPT

iptables -I INPUT -p udp –dport 2082 -j ACCEPT

iptables -I OUTPUT -p tcp –dport 2082 -j ACCEPT

iptables -I OUTPUT -p udp –dport 2082 -j ACCEPT

To drop (block) port in iptables you have to follow below commands:

iptables -I INPUT -p tcp –dport 2082 -j DROP

iptables -I INPUT -p udp –dport 2082 -j DROP

iptables -I OUTPUT -p tcp –dport 2082 -j DROP

iptables -I OUTPUT -p udp –dport 2082 -j DROP

After adding or removing iptables you need to save iptable rule using following command.

  • service iptables save
  • service iptables restart

To enable range of port in iptables

 
iptables -A INPUT -p tcp –destination-port 1568:1570 -j ACCEPT

iptables -A OUTPUT -p tcp –source-port 1568:1570 -j ACCEPT

 
  • service iptables save

  • service iptables restart

Advertisements

December 14, 2011 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: