Saturday 29 June 2013

IPTABLES CONFIGURATION

IP-TABLES Configuration

# iptables -I INPUT -p tcp -s 192.168.0.6 -m time --weekdays Tu  --dport 22 -j REJECT 

(Here a/c to this rule 22 port is block on every tuesday for this source)

# iptables -I INPUT -p tcp -s 192.168.0.6 -m time --weekdays Tu  -m time --timestart 17:00 --timestop 17:30 --dport 22 -j REJECT 


(Here a/c to this rule 22 port is block for source on tuesday only between
5:00 pm to 5:30 pm)# iptables -I INPUT -p tcp -s 192.168.0.6  -m time --datestart 2012-06-05 --datestop 2012-06-06 --dport 22 -j REJECT

(Here a/c to this rule 22 port block for source from 05-06-2012 to 06-06-2012)

# iptables -I INPUT -p tcp -s 192.168.0.6  -m time --datestart 2012-06-05T17:20 --datestop 2012-06-06T17:45 --dport 22 -j REJECT 

(Here a/c to this rule 22 port is block for source from 05-06-2012 to 06-06-2012 between 5:20 pm to 5:45 pm)

Allow Limited connection of ssh

If you want to allow limited connetion for specific service like ssh->
You can adjust the numbers yourself to limit connections further, so the following example will drop incoming connections which make more than 2 connection attempts upon port22 within ten minutes:


[root@piyush~]#iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent  --set


[root@piyush~]#iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent  --update --seconds 600 --hitcount 2 -j DROP

No comments:

Post a Comment