Skip to content

Instantly share code, notes, and snippets.

@marktopper
Last active August 29, 2015 14:21
Show Gist options
  • Save marktopper/a40c07754bc160b9b850 to your computer and use it in GitHub Desktop.
Save marktopper/a40c07754bc160b9b850 to your computer and use it in GitHub Desktop.
# Manually secure port 6379
sudo iptables -A INPUT -p tcp --dport 6379 -s xxx.xxx.xxx.xxx -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 6379 -j DROP
sudo iptables -L
# Save current firewall config
# sudo iptables-save > /etc/iptables.conf
# Above removed - Mark
sudo bash -c "iptables-save > /etc/iptables.conf"
# Load iptables.conf on startup
sudo nano /etc/rc.local
# Add the following:
# Load iptables rules from this file
iptables-restore < /etc/iptables.conf
# EXAMPLE:
# Generated by iptables-save v1.4.12 on Thu Oct 17 19:46:50 2013
*filter
:INPUT ACCEPT [4316:515188]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [15307:1118735]
-A INPUT -s xxx.xxx.xxx.xxx/32 -p tcp -m tcp --dport 6379 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 6379 -j DROP
COMMIT
# Completed on Thu Oct 17 19:46:50 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment