-
-
Save nivv/de0cf110131f830e37fc to your computer and use it in GitHub Desktop.
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
# Run as root or use sudo | |
$ sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
$ sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT | |
$ sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT | |
$ sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT | |
$ sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT | |
$ sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT | |
$ sudo iptables -A INPUT -j DROP | |
$ sudo iptables -I INPUT 1 -i lo -j ACCEPT | |
# Save iptables config | |
$ sudo iptables-save | sudo tee /etc/iptables/rules.v4 | |
$ sudo service iptables-persistent restart | |
# Install and use so firewalls are saved through restarts | |
$ sudo apt-get install -y iptables-persistent | |
$ sudo service iptables-persistent start | |
// Source: https://serversforhackers.com/editions/2014/06/17/more-security/ | |
// Source 2: http://fideloper.com/ubuntu-12-04-lemp-nginx-setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment