Last active
October 29, 2015 08:43
-
-
Save Hyunho/46b9f1b72bfa1f25a56e to your computer and use it in GitHub Desktop.
iptables_rule(only allow ssh connection)
This file contains hidden or 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
# using firewalld utility | |
firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -p tcp -m tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT | |
firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT | |
firewall-cmd --direct --add-rule ipv4 filter OUTPUT 1 -p tcp -m multiport --dports 200:65535 -j DROP |
This file contains hidden or 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
#!/bin/bash | |
# Only allow ssh connection. | |
# And boud a specific destnation range ports(200~65535) to block unhappy connection | |
# clear iptables | |
sudo iptables -F | |
# set policy | |
sudo iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT | |
sudo iptables -A OUTPUT -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT | |
sudo iptables -A OUTPUT -p tcp -m multiport --dports 200:65535 -j DROP | |
# list | |
sudo iptables -L |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment