Iptables on Ubuntu

This page discusses allowing services, opening ports and restricting ip address access for inbound and outbound traffic using iptables, The following sites are useful iptables1 iptables2 redhat

an example of iptables commands would be

sudo iptables -A INPUT -p tcp –destination-port 80 -j ACCEPT

sudo iptables -A INPUT -p tcp –destination-port 22 -m iprange –src-range -j ACCEPT

sudo iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT (this line is needed to allow established connections freedom to communicate (for example if you are trying to communicate with a proxy server through apt-get you will need this line, the initial connections through port 80 is not enough, the proxy server will want to continue communicating with this machine and is unable to do so if this line is not entered)

sudo iptables -P INPUT DROP

This bit is optional but I made it accept everything on localhost

iptables -A INPUT -s -j ACCEPT

sudo iptables-save


One thought on “Iptables on Ubuntu

  1. Pingback: Steps to consider (Post creation of Ubuntu Linux server) « RUBRIC Tech Team

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s