Last active
December 11, 2015 19:48
-
-
Save justjohn/4650817 to your computer and use it in GitHub Desktop.
iptables rules for a KVM host box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*filter | |
# Accepts all established inbound connections | |
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# Allows all outbound traffic | |
-A OUTPUT -j ACCEPT | |
# Allows HTTP and HTTPS connections from anywhere | |
-A INPUT -p tcp --dport 443 -j ACCEPT | |
-A INPUT -p tcp --dport 80 -j ACCEPT | |
# Allows SSH connections | |
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT | |
# Allow connections from loopback and KVM virtual network adapter | |
-A INPUT -i lo -j ACCEPT | |
-A INPUT -i virbr0 -j ACCEPT | |
# Allow ping | |
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT | |
# log iptables denied calls (access via 'dmesg' or /var/log/syslog) | |
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 | |
# Reject all other inbound - default deny unless explicitly allowed policy: | |
-A INPUT -j REJECT | |
# Disabled to allow hosted VMs access to the external network | |
# A much better solution would only forward the subnet with the VMs. | |
# -A FORWARD -j REJECT | |
COMMIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment