<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Firewall_Example</id>
	<title>Firewall Example - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Firewall_Example"/>
	<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Firewall_Example&amp;action=history"/>
	<updated>2026-04-17T12:15:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.scott5.org/index.php?title=Firewall_Example&amp;diff=636&amp;oldid=prev</id>
		<title>Scott: Created page with &#039;&lt;pre&gt; #!/bin/sh  if [ -r /lib/lsb/init-functions ]; then     . /lib/lsb/init-functions fi  firewall_start() {     # Flush all rules     iptables -F INPUT     iptables -F OUTPUT  …&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Firewall_Example&amp;diff=636&amp;oldid=prev"/>
		<updated>2011-02-14T23:41:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;pre&amp;gt; #!/bin/sh  if [ -r /lib/lsb/init-functions ]; then     . /lib/lsb/init-functions fi  firewall_start() {     # Flush all rules     iptables -F INPUT     iptables -F OUTPUT  …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ -r /lib/lsb/init-functions ]; then&lt;br /&gt;
    . /lib/lsb/init-functions&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
firewall_start()&lt;br /&gt;
{&lt;br /&gt;
    # Flush all rules&lt;br /&gt;
    iptables -F INPUT&lt;br /&gt;
    iptables -F OUTPUT&lt;br /&gt;
    iptables -F FORWARD&lt;br /&gt;
&lt;br /&gt;
    # Default policies&lt;br /&gt;
    iptables -P INPUT   DROP&lt;br /&gt;
    iptables -P OUTPUT  ACCEPT&lt;br /&gt;
    iptables -P FORWARD DROP&lt;br /&gt;
&lt;br /&gt;
    # Allow everything on the loopback network&lt;br /&gt;
    iptables -A INPUT -i lo -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Allow ICMP&lt;br /&gt;
    iptables -A INPUT --protocol icmp -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Allow everything from the home server&lt;br /&gt;
    iptables -A INPUT --source 123.45.67.89 -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Allow established sessions&lt;br /&gt;
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Allow incoming SSH sessions&lt;br /&gt;
    iptables -A INPUT --protocol tcp --dport 22 --source 123.45.0.0/16 -m state --state NEW -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Allow incoming nfs4&lt;br /&gt;
    iptables -A INPUT --protocol tcp --dport 2049 --source 123.45.0.0/16 -m state --state NEW -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Allow samba&lt;br /&gt;
    iptables -A INPUT --protocol tcp --dport 139 --source 123.45.0.0/16 -m state --state NEW -j ACCEPT&lt;br /&gt;
    iptables -A INPUT --protocol tcp --dport 445 --source 123.45.0.0/16 -m state --state NEW -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
    # Drop intranet broadcasts&lt;br /&gt;
    iptables -A INPUT --protocol udp --destination 123.45.67.255 -j DROP&lt;br /&gt;
&lt;br /&gt;
    # Drop other packets&lt;br /&gt;
    iptables -A INPUT   -j DROP&lt;br /&gt;
    iptables -A FORWARD -j DROP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
firewall_stop()&lt;br /&gt;
{&lt;br /&gt;
    # Flush all rules&lt;br /&gt;
    iptables -F INPUT&lt;br /&gt;
    iptables -F OUTPUT&lt;br /&gt;
    iptables -F FORWARD&lt;br /&gt;
&lt;br /&gt;
    # Default policies&lt;br /&gt;
    iptables -P INPUT   ACCEPT&lt;br /&gt;
    iptables -P OUTPUT  ACCEPT&lt;br /&gt;
    iptables -P FORWARD ACCEPT&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
    start)&lt;br /&gt;
        log_begin_msg &amp;quot;Starting firewall...&amp;quot;&lt;br /&gt;
        firewall_start&lt;br /&gt;
        log_end_msg 0&lt;br /&gt;
        ;;&lt;br /&gt;
&lt;br /&gt;
    stop)&lt;br /&gt;
        log_begin_msg &amp;quot;Stopping firewall...&amp;quot;&lt;br /&gt;
        firewall_stop&lt;br /&gt;
        log_end_msg 0&lt;br /&gt;
        ;;&lt;br /&gt;
&lt;br /&gt;
    restart)&lt;br /&gt;
        log_begin_msg &amp;quot;Restarting firewall...&amp;quot;&lt;br /&gt;
        firewall_stop&lt;br /&gt;
        firewall_start&lt;br /&gt;
        log_end_msg 0&lt;br /&gt;
        ;;&lt;br /&gt;
&lt;br /&gt;
    *)&lt;br /&gt;
        echo &amp;quot;Usage: $0 {start|stop|restart}&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Scott</name></author>
	</entry>
</feed>