Skip to content

Instantly share code, notes, and snippets.

@cerealskill
Created May 29, 2017 15:52
Show Gist options
  • Select an option

  • Save cerealskill/6278042ef8c176f4422c633e293c3571 to your computer and use it in GitHub Desktop.

Select an option

Save cerealskill/6278042ef8c176f4422c633e293c3571 to your computer and use it in GitHub Desktop.
Firewall Iptables CentOS 6.x (Script de inicio)
#!/bin/bash
# Open port 53 on firewall (iptables) Only for CentOS 6.X
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p icmp -j ACCEPT # (Ping)
sudo iptables -A INPUT -i lo -j ACCEPT # (localhost)
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT # SSH-Acceso
sudo iptables -I INPUT -p tcp -m tcp --dport 53 -j ACCEPT # DNS
sudo iptables -I INPUT -p udp -m udp --dport 53 -j ACCEPT # DNS
iptables -A INPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT # DNS
iptables -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT # DNS
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT # httpd24-httpd (Apache Web)
sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT # MySQL
sudo iptables -P INPUT DROP # DROP ALL
sudo service iptables save # guardamos las reglas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment