    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>Linux.com :: Build dmz server for windows sharing printer using iptables</title>
        <link>http://www.linux.com/archive/forums/topic/52</link>
        <description>Everything Linux and Open Source</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Linux.com Admin</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.linux.com" /> 
        <admin:errorReportsTo rdf:resource="mailto:noreply@linux.com" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>



<div class="xarbb-noteswrapper">
</div>

   <div class="xarbb-noteswrapper">
       <div class="xar-sub rightnote">
           <div>
                    <a href="http://www.linux.com/archive/forums/topic/20">
Previous Topic</a>
|
                    <a href="http://www.linux.com/archive/forums/topic/64">
Next Topic</a>
</div>

           <div>
                    <a href="http://www.linux.com/archive/forums/printtopic/52?theme=print">
Print this topic</a> |
You are not subscribed            </div>
        </div>
        <div style="clear: both;"></div>
    </div>

    <h1>
        <a class="xar-title" href="http://www.linux.com/archive/forums/topic/52">Build dmz server for windows sharing printer using iptables</a>
   </h1>


   <div class="xarbb-topiccontrols">
<form action="http://www.linux.com/archive/forums?func=jump" method="post">
   <label for="xarbb_jump_menu">Forum Jump</label>
    <select name="f" id="xarbb_jump_menu" onchange="this.form.submit();">
        <optgroup label="Options">
            <option value="6" selected="selected">
Please select forum            </option>
            <option value="6">--------------------</option>
        </optgroup>
        <optgroup label="Forums">
                <option value="1">New to Linux</option>
                <option value="2">Hardware</option>
                <option value="3">Linux Distributions</option>
                <option value="4">Applications</option>
                <option value="5">Programming and Development</option>
                <option value="6">Miscellaneous Discussion</option>
                <option value="7">Linux.com Writers Forum</option>
                <option value="8">Jobs</option>
        </optgroup>
    </select>
    <input type="submit" class="button" value="Jump" />
</form>
<div style="clear: both;"></div>
   </div>

   <div class="xarbb-topiccontrols">

<span class="xar-sub">
    <a href="http://www.linux.com/archive/forums">
Forum Index    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/category/4181">
        Forums 
    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/forum/6">
        Miscellaneous Discussion   </a>
</span>
<div style="clear: both;"></div>
   </div>

<div class="xarbb-tablewrapper">



   <table>
       <tr>
           <th scope="col">
Author</th>
           <th scope="col">
Message</th>
       </tr>



            <tr>
                <td class="xar-norm author">
                    <div>
                        <a href="http://www.linux.com/archive/roles/386134">Andi Purwito</a>
                   </div>
                   <div class="xar-sub">
Joined: Jul 24, 2007<br/>Posts: 1                        <br />
                        <a href="http://www.linux.com/archive/forums?by=386134&amp;func=searchtopics">
Other Topics</a>
                   </div>
               </td>

               <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted Jul 25, 2007 at 8:57:28 AM</span>
                       </div>



<div style="float: left;">
                           <strong class="xar-sub">
Subject: Build dmz server for windows sharing printer using iptables                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div>
                        I have no idea with my script below. I don't know where the mismatch. I plan to build a DMZ Server for windows sharing printer with this script, but not work. However DMZ for web server is done successfully. Please help me!


FW_HOSTNAME=&quot;DMZ&quot;
KDCAB=&quot;5&quot;
NETMASK_LAMA=&quot;netmask 255.255.255.0&quot;
GW_LAMA=&quot;192.168.128.1&quot; #IP Address Modem VSAT

NAT_ADDRESS_LAN=&quot;192.168.128.254&quot;
BUFFER=&quot;32767500&quot; # BUFFER = 65535 * 500

#Network Data Center
ETH_DC=&quot;eth0&quot;
NET_DC=&quot;192.168.128.0/24&quot;

#Network Local Cabang
ETH_LOCAL=&quot;eth1&quot;
NET_LOCAL=&quot;192.168.$KDCAB.0/24&quot;

GOTOHELL=&quot;DROP&quot;
ipt=&quot;iptables&quot;
SPOK=&quot;--sport 1024:65535&quot;
VIRUS_ALERT=&quot;0&quot;

#*************************
# SETTING NETWORKING
#*************************
# Setting HOSTNAME
hostname $FW_HOSTNAME

#Setting DNS Address
echo &quot;nameserver $FW_NAMESERVER&quot; &gt; /etc/resolv.conf

# Enabling IPV4 Forwarding
echo 1 &gt; /proc/sys/net/ipv4/ip_forward

# Static route
route del -net $NET_DC gw $GW_LAMA
route del -net default gw $GW_LAMA
route add -net $NET_DC gw $GW_LAMA
route add -net default gw $GW_LAMA

#Load module for FTP Connection tracking and NAT
modprobe ip_conntrack
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
modprobe iptable_nat

# Setting buffer
#DEFAULT = 65535 - Tergantung RAM size
echo $BUFFER &gt; /proc/sys/net/ipv4/netfilter/ip_conntrack_max

# Drop ICMP echo-request messages sent to broadcast or multicast addresses
echo 1 &gt; /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

# Drop source routed packets
echo 0 &gt; /proc/sys/net/ipv4/conf/all/accept_source_route

# Enable TCP SYN cookie protection from SYN floods
echo 1 &gt; /proc/sys/net/ipv4/tcp_syncookies

# Don't accept ICMP redirect messages
echo 0 &gt; /proc/sys/net/ipv4/conf/all/accept_redirects

# Don't send ICMP redirect messages
echo 0 &gt; /proc/sys/net/ipv4/conf/all/send_redirects

# Enable source address spoofing protection
echo 1 &gt; /proc/sys/net/ipv4/conf/all/rp_filter

# Log packets with impossible source addresses
echo $VIRUS_ALERT &gt; /proc/sys/net/ipv4/conf/all/log_martians

#Initialization all the chains
$ipt --flush
$ipt -t nat --flush
$ipt -t mangle --flush

#Initialization the user defined chains
$ipt --delete-chain
$ipt -t nat --delete-chain
$ipt -t mangle --delete-chain

#Set policy
$ipt --policy INPUT DROP
$ipt --policy OUTPUT DROP
$ipt --policy FORWARD DROP
$ipt -t nat --policy POSTROUTING ACCEPT
$ipt -t nat --policy PREROUTING ACCEPT

#DMZ
$ipt -t nat -A PREROUTING -i $ETH_DC -p TCP --dport 80 -j DNAT --to-destination 192.168.5.10:80
$ipt -t nat -A PREROUTING -i $ETH_DC -p TCP --dport 137 -j DNAT --to-destination 192.168.5.22:137
$ipt -t nat -A PREROUTING -i $ETH_DC -p UDP --dport 137 -j DNAT --to-destination 192.168.5.22:137
$ipt -t nat -A PREROUTING -i $ETH_DC -p UDP --dport 138 -j DNAT --to-destination 192.168.5.22:138
$ipt -t nat -A PREROUTING -i $ETH_DC -p TCP --dport 139 -j DNAT --to-destination 192.168.5.22:139
$ipt -t nat -A PREROUTING -i $ETH_DC -p UDP --dport 139 -j DNAT --to-destination 192.168.5.22:139
$ipt -t nat -A PREROUTING -i $ETH_DC -p TCP --dport 445 -j DNAT --to-destination 192.168.5.22:445

#NAT untuk Local Area Network
$ipt -t nat -A POSTROUTING -o $ETH_DC -j SNAT --to-source $NAT_ADDRESS_LAN

#SSH ke FIREWALL dari DATACENTER
$ipt -A INPUT -p TCP -i $ETH_DC --dport ssh -j ACCEPT

#DMZ
$ipt -A INPUT -p TCP -m tcp $SPOK --dport 137 -j ACCEPT
$ipt -A INPUT -p UDP -m udp $SPOK --dport 137 -j ACCEPT
$ipt -A INPUT -p UDP -m udp $SPOK --dport 138 -j ACCEPT
$ipt -A INPUT -p TCP -m tcp $SPOK --dport 139 -j ACCEPT
$ipt -A INPUT -p UDP -m udp $SPOK --dport 139 -j ACCEPT
$ipt -A INPUT -p TCP -m tcp $SPOK --dport 445 -j ACCEPT
$ipt -A INPUT -p UDP -m udp $SPOK --dport 445 -j ACCEPT


#Allways allow unlimited traffic on the loopback interface
$ipt -A INPUT -p all -i lo -j ACCEPT
$ipt -A OUTPUT -p all -o lo -j ACCEPT

# Previously initiated and accepted exchanges bypass rule checking
$ipt -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ipt -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

#Allowing PING test to this firewall and across between network
$ipt -A INPUT -p icmp -j ACCEPT
$ipt -A OUTPUT -p icmp -j ACCEPT
$ipt -A FORWARD -p icmp -j ACCEPT

#=================================
# APLIKASI PUBLIK/UMUM UTK SEMUA
#=================================
$ipt -N PUBLIK
$ipt -A FORWARD -j PUBLIK
#FTP Control Connection
$ipt -A PUBLIK -p TCP $SPOK --dport ftp -j ACCEPT
$ipt -A PUBLIK -p UDP $SPOK --dport ftp -j ACCEPT
#FTP Data Transfer
$ipt -A PUBLIK -p TCP $SPOK --dport ftp-data -j ACCEPT
$ipt -A PUBLIK -p UDP $SPOK --dport ftp-data -j ACCEPT

#SMTP
$ipt -A PUBLIK -p TCP $SPOK --dport smtp -j ACCEPT
$ipt -A PUBLIK -p TCP $SPOK --dport smtps -j ACCEPT
#IMAP
$ipt -A PUBLIK -p TCP $SPOK --dport imap -j ACCEPT
$ipt -A PUBLIK -p TCP $SPOK --dport imaps -j ACCEPT
#Web mail server
$ipt -A PUBLIK -p TCP $SPOK --dport 8080 -j ACCEPT
$ipt -A PUBLIK -p TCP $SPOK --dport 5432 -j ACCEPT
#POP3
$ipt -A PUBLIK -p TCP $SPOK --dport pop3 -j ACCEPT
$ipt -A PUBLIK -p TCP $SPOK --dport pop3s -j ACCEPT
#DNS/Domain/Name Server
$ipt -A PUBLIK -p UDP $SPOK --dport 53 -j ACCEPT
#Web access server
$ipt -A PUBLIK -p TCP $SPOK --dport http -j ACCEPT
$ipt -A PUBLIK -p TCP $SPOK --dport https -j ACCEPT
#Remote Desktop
$ipt -A PUBLIK -p TCP $SPOK --dport 3389 -j ACCEPT
#DMZ
$ipt -A PUBLIK -p TCP -m tcp $SPOK --dport 137 -j ACCEPT
$ipt -A PUBLIK -p UDP -m udp $SPOK --dport 137 -j ACCEPT
$ipt -A PUBLIK -p UDP -m udp $SPOK --dport 138 -j ACCEPT
$ipt -A PUBLIK -p TCP -m tcp $SPOK --dport 139 -j ACCEPT
$ipt -A PUBLIK -p UDP -m udp $SPOK --dport 139 -j ACCEPT
$ipt -A PUBLIK -p TCP -m tcp $SPOK --dport 445 -j ACCEPT
$ipt -A PUBLIK -p UDP -m udp $SPOK --dport 445 -j ACCEPT

#Allow previously ESTABLISHED FORWARD connection
$ipt -A FORWARD -p ALL -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

#Telnet &amp; SSH keluar
$ipt -A OUTPUT -p TCP --dport telnet -m state --state NEW -j ACCEPT
$ipt -A OUTPUT -p TCP --dport ssh -m state --state NEW -j ACCEPT

#Allow previously connection
$ipt -A OUTPUT -s 127.0.0.1 -j ACCEPT
$ipt -A OUTPUT -p ALL -m state --state RELATED,ESTABLISHED -j ACCEPT</div>

                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/52#top">
Back to top</a>
</td>
               <td class="xar-alt">

                        <a href="http://www.linux.com/archive/roles/386134">
                            <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                        </a>
                        <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=386134">
                            <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                       </a>
                            <a href="http://">
                                <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                           </a>
</td>
           </tr>





           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/344947">
                                Joe Barr                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Nov 23, 2009<br/>Posts: 146<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=344947&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-accent message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Sep 11, 2007 12:52:21 PM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1165338" href="http://www.linux.com/archive/forums/topic/52#1165338">
                                    Build dmz server for windows sharing printer using iptables                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        Where did you get this script?                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/52#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/344947">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=344947">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/399680">
                                                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Nov 23, 2009<br/>Posts: 241<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=399680&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Mar 18, 2008 10:12:13 PM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1185272" href="http://www.linux.com/archive/forums/topic/52#1185272">
                                    Build dmz server for windows sharing printer using iptables                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        dont worked any platform. thanks.                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/52#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/399680">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=399680">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
</td>
           </tr>
</table>
</div>

<div class="xarbb-topiccontrols">

<span class="xar-sub">
    <a href="http://www.linux.com/archive/forums">
Forum Index    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/category/4181">
        Forums 
    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/forum/6">
        Miscellaneous Discussion   </a>
</span>

</div>



            </channel>
</rss>
