How do I use Iptables in Linux?

Problem

I need to setup iptables on my spinup server

Solution

Iptables is a utility that comes standard in secure linux servers.  It provides a host-level firewall that is separate from any external firewalls (security group in amazon, or yale's firewall in our datacenters).

Note that if you are using a server in a high-risk space (from CIS image) iptables is used on both CentOS and Ubuntu servers, i.e. Ubuntu does not use ufw and it will show inactive.

Best Practices

  • Keep iptables enabled on any server that needs to be secure
  • Only allow particular IPs and ports. Do not just allow everything (0.0.0.0/0)
  • Save your Iptables rules after modification . "sudo service iptables save"