<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux, Programming, Telephony, Asterisk, Apache, Tips &#38; Tricks &#187; firewall</title>
	<atom:link href="http://shahidz.com/tag/firewall/feed/" rel="self" type="application/rss+xml" />
	<link>http://shahidz.com</link>
	<description>Passionate About Technology</description>
	<lastBuildDate>Sun, 10 Jan 2010 17:38:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Configuring Iptables on system startup</title>
		<link>http://shahidz.com/configuring-iptables-on-system-startup/</link>
		<comments>http://shahidz.com/configuring-iptables-on-system-startup/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 08:59:41 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Script]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[Iptables]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[stop]]></category>

		<guid isPermaLink="false">http://shahidz.com/configuring-iptables-on-system-startup/</guid>
		<description><![CDATA[In Ubuntu we don&#8217;t have a mechanism to start or stop iptables or we don&#8217;t have a mechanism to restore iptables after restarting the system. Now we will see how to create a script for start and stop iptables also to make the script to start on system startup.
1. Create a Firewall script
 vim /etc/set_iptables.bash
echo 1 [...]]]></description>
			<content:encoded><![CDATA[<p>In Ubuntu we don&#8217;t have a mechanism to start or stop <a href="http://shahidz.com/tag/iptables/" title="Iptables" target="_blank">iptables</a> or we don&#8217;t have a mechanism to restore <a href="http://shahidz.com/tag/iptables/" target="_blank">iptables</a> after restarting the system. Now we will see how to create a script for start and stop iptables also to make the script to start on system startup.</p>
<p>1. Create a Firewall script</p>
<pre> vim /etc/set_iptables.bash</pre>
<pre>echo 1 &gt; /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -i eth0 -d 192.168.0.10 --dport 555 -j DNAT --to 192.168.0.12:22
iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.12 --dport 22 -j ACCEPT</pre>
<p>2. Change the file permission mod</p>
<pre>sudo chmod o+x /etc/set_iptables.bash</pre>
<p>3. Create a start.stop script</p>
<pre>vim /etc/init.d/iptables</pre>
<pre>#!/bin/bash

RETVAL=0

# To start the firewall
start() {
  echo -n "Iptables rules creation: "
  /etc/set_iptables.bash
  RETVAL=0
}

# To stop the firewall
stop() {
  echo -n "Removing all iptables rules: "
  /sbin/iptables -F
  RETVAL=0
}

case $1 in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  status)
    /sbin/iptables -L
    /sbin/iptables -t nat -L
    RETVAL=0
    ;;
  *)
    echo "Usage: iptables {start|stop|restart|status}"
    RETVAL=1
esac
exit</pre>
<p>4. Change the file permission mod</p>
<pre>sudo chmod o+x /etc/init.d/iptables</pre>
<p>5. The final step is to make your script running on each boot of your computer:</p>
<pre>sudo update-rc.d iptables defaults</pre>
<p>Now you can use these commands to start/stop/restart/status your iptables.</p>
<pre>sudo /etc/init.d/iptables start
sudo /etc/init.d/iptables stop
sudo /etc/init.d/iptables restart
sudo /etc/init.d/iptables status</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fconfiguring-iptables-on-system-startup%2F&amp;linkname=Configuring%20Iptables%20on%20system%20startup"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/configuring-iptables-on-system-startup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ufw &#8211; Uncomplicated Firewall</title>
		<link>http://shahidz.com/ufw-uncomplicated-firewall/</link>
		<comments>http://shahidz.com/ufw-uncomplicated-firewall/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 16:12:17 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Iptables]]></category>
		<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ufw]]></category>

		<guid isPermaLink="false">http://shahidz.com/ufw-uncomplicated-firewall/</guid>
		<description><![CDATA[Description
ufw is stands for Uncomplicated Firewall, this program is for managing a Linux firewall and aims to provide an easy to use interface for the user, as well as support package integration and dynamic-detection of open ports. ufw  is not intended to provide complete firewall functionality via its command interface, but instead provides an easy [...]]]></description>
			<content:encoded><![CDATA[<h3>Description</h3>
<p align="justify">ufw is stands for Uncomplicated Firewall, this program is for managing a Linux firewall and aims to provide an easy to use interface for the user, as well as support package integration and dynamic-detection of open ports. ufw  is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to  add  or  remove simple rules. It is currently mainly used for host-based firewalls.</p>
<h3 align="justify">Installation</h3>
<pre>$ sudo apt-get install ufw</pre>
<p>For help use</p>
<pre>$ man ufw</pre>
<p>To enable firewall</p>
<pre>$ sudo ufw enable</pre>
<p>When we enable the firewall it will set firewall with default settings, it will deny ssh ports, telnet and many other services. So when we enable firewall on the remort servers we must enable ssh ports first, this can done using.</p>
<pre>$ ufw allow proto tcp from any to any port 22</pre>
<p>To disable a firewall</p>
<pre>$ sudo sfw disable</pre>
<p>Examples</p>
<p>Deny all access to port 53:</p>
<pre>$ sudo ufw deny 53</pre>
<p>Allow all access to tcp port 80:</p>
<pre>$ sudo ufw allow 80/tcp</pre>
<p>Allow all access from RFC1918 networks to this host:</p>
<pre>$ sudo ufw allow from 10.0.0.0/8
$ sudo ufw allow from 172.16.0.0/12
$ sudo ufw allow from 192.168.0.0/16</pre>
<p>Deny access to udp port 514 from host 1.2.3.4:</p>
<pre>$ sudo ufw deny proto udp from 1.2.3.4 to any port 514</pre>
<p>Allow access to udp 1.2.3.4 port 5469 from 1.2.3.5 port 5469:</p>
<pre>$ sudo ufw allow proto udp from 1.2.3.5 port 5469 to 1.2.3.4 port 5469</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fufw-uncomplicated-firewall%2F&amp;linkname=ufw%20%26%238211%3B%20Uncomplicated%20Firewall"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/ufw-uncomplicated-firewall/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
