Common Linux iptables firewall rules

iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

# Allow the local loopback interface (i.e., access to the machine running native)


iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  

  # Allow established or even relevant passage


iptables -A OUTPUT -j ACCEPT        

Allows access to all local # outwardly


iptables -A INPUT -p tcp --dport 22 -j ACCEPT   

# Allow access to port 22


iptables -A INPUT -p tcp --dport 80 -j ACCEPT   

# Allow access to port 80


iptables -A INPUT -p tcp --dport 21 -j ACCEPT   

# 21 port allows ftp services


iptables -A INPUT -p tcp --dport 20 -j ACCEPT   

# FTP services allow port 20


iptables -A INPUT -j reject      

# Prohibit other rules are not allowed access


iptables -A FORWARD -j REJECT    

# Prohibit other rules are not allowed access

Guess you like

Origin www.cnblogs.com/gavinpan/p/11220474.html