Showing posts with label useful iptables commands. Show all posts
Showing posts with label useful iptables commands. Show all posts

Thursday, 22 August 2013

Useful IP Tables commands


Blocking IP’s using IP Tables

iptables -I INPUT -s xxx.xxx.xxx.xxx -j DROP
 
 

OR just for port 80

Iptables –A INPUT –src xxx.xxx.xxx.xxx –p tcp --dport 80 –j REJECT
 
 

Block PING

iptables -A INPUT -p icmp -m state --state NEW -j DROP



Port Redirection
This is useful if you need to access email on a different port due to ISP restrictions.
 

# Allow incoming port 587 (tcp) SMTP traffic, and redirect it to port 25

/sbin/iptables -A INPUT -p tcp --dport 587 -j ACCEPT

/sbin/iptables -A PREROUTING -t nat -p tcp --dport 587 -j REDIRECT --to-port 25