Skip to content

Instantly share code, notes, and snippets.

@DavidGarciaCat
Created January 28, 2016 10:14
Show Gist options
  • Select an option

  • Save DavidGarciaCat/4bbcff00af0b9650d577 to your computer and use it in GitHub Desktop.

Select an option

Save DavidGarciaCat/4bbcff00af0b9650d577 to your computer and use it in GitHub Desktop.
GNU/Linux Firewall - Default rules
#!/bin/bash
# ****************************************************************
# IPTables path
# ****************************************************************
IPT=/sbin/iptables
# ****************************************************************
# Remove/Erase old rules
# ****************************************************************
$IPT -F
$IPT -X
$IPT -Z
$IPT -t nat -F
$IPT -t nat -X
$IPT -t nat -Z
# ****************************************************************
# By default policy:
# ALLOW Output
# DENY Input & Forward
# ****************************************************************
$IPT -P INPUT DROP
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD DROP
# ****************************************************************
# ALLOW Input from `Local Host`
# ****************************************************************
$IPT -A INPUT -i lo -j ACCEPT
# ****************************************************************
# ALLOW Input just if it is a response from one of our requests
# ****************************************************************
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment