<?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>NerdGrind - How-to Computer Help - Tutorials - Tech and Gadget News &#187; iptables</title> <atom:link href="http://www.nerdgrind.com/tag/iptables/feed/" rel="self" type="application/rss+xml" /><link>http://www.nerdgrind.com</link> <description>Gadget and technology news, computer help, and how-to tutorials on everything, from your friendly nerd at NerdGrind</description> <lastBuildDate>Tue, 17 Nov 2009 20:03:16 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Set up NAT with Linux and iptables Firewall</title><link>http://www.nerdgrind.com/set-up-nat-with-linux-and-iptables-firewall/</link> <comments>http://www.nerdgrind.com/set-up-nat-with-linux-and-iptables-firewall/#comments</comments> <pubDate>Sun, 03 Feb 2008 17:49:04 +0000</pubDate> <dc:creator>Nerd Grind</dc:creator> <category><![CDATA[How to Linux]]></category> <category><![CDATA[Linux Network and Internet]]></category> <category><![CDATA[iptables]]></category> <category><![CDATA[OLED]]></category><guid
isPermaLink="false">http://www.nerdgrind.com/set-up-nat-with-linux-and-iptables-firewall/</guid> <description><![CDATA[<img
src="http://images.nerdgrind.com:9000/images/icons/linux2.png" width="24" height="28" alt="linux2 Set up NAT with Linux and iptables Firewall"  title="Set up NAT with Linux and iptables Firewall" /><br/>This step-by-step tutorial shows how to set up Network Address Translation (NAT) with Open Source Linux operating system and iptables firewall. This will allow your system to act as gateway and to provide Internet access to multiple hosts in Local Area Network (LAN) using a single public IP address.]]></description> <content:encoded><![CDATA[<img
src="http://images.nerdgrind.com:9000/images/icons/linux2.png" width="24" height="28" alt="linux2 Set up NAT with Linux and iptables Firewall"  title="Set up NAT with Linux and iptables Firewall" /><br/><p>This step-by-step tutorial shows how to set up Network Address Translation (NAT) with Open Source <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.linux.org"  target="_blank" >Linux</a> operating system and <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.netfilter.org/projects/iptables/index.html"  target="_blank" >iptables firewall</a>. This will allow your system to act as gateway and to provide Internet access to multiple hosts in Local Area Network (LAN) using a single public IP address.</p><p><strong>Requirements</strong></p><p>1. Hardware server with 2 (two) network interface cards (NICs).<br
/>2. Any Linux distribution (get more information at <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.distrowatch.com"  target="_blank" >DistroWatch.com</a>).<br
/>3. Linux <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.kernel.org"  target="_blank" >kernel</a> with networking and iptables support.<br
/>4. iptables package (you can find latest release at <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.netfilter.org/projects/iptables/downloads.html"  target="_blank" >NetFilter&rsquo;s Download</a> page).</p><p><strong>Basic definitions</strong></p><p><i>aa.aa.aa.aa</i> is Wide Area Network (WAN) IP address (<i>bb.bb.bb.bb</i> is WAN netmask).<br
/><i>cc.cc.cc.cc</i> is LAN IP address (e.g. <i>192.168.0.1</i> or <i>10.0.0.1</i>), <i>dd.dd.dd.dd</i> is LAN netmask (e.g. <i>255.255.255.0</i>).<br
/><i>ee.ee.ee.ee</i> is default gateway for Internet connection.</p><p>eth0 is hardware name of the NIC connected to WAN base.<br
/>eth1 is name of LAN connected NIC.</p><p><strong>Step-by-step set up</strong></p><p><strong>1.</strong> Apply two NICs to hardware server.<br
/><strong>2.</strong> Verify that both NICs are recognized by Linux well and are fully workable:</p><blockquote><pre>dmesg | grep eth0
dmesg | grep eth1
</pre></blockquote><p>the output may vary but in most cases it would be like following one:</p><blockquote><pre>eth1: RealTek RTL8139 at 0xe0830000, 00:30:4f:3b:af:45, IRQ 19
eth1:  Identified 8139 chip type &rsquo;RTL-8100B/8139D&rsquo;
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
</pre></blockquote><p>Similar output should be for eth0 NIC.</p><p>To verify that NICs are recognized by Linux as networking devices use the following commands:</p><blockquote><pre>ifconfig eth0
ifconfig eth1
</pre></blockquote><p>In case of success the output will be as follows:</p><blockquote><pre>eth0      Link encap:Ethernet  HWaddr 00:50:56:C0:00:08
          inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
</pre></blockquote><p>You can find full manual page for <i>ifconfig</i> command <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://linux.die.net/man/8/ifconfig"  target="_blank" >here</a>.</p><p><strong>3.</strong> Configure WAN interface (eth0) to get Internet connection:</p><blockquote><pre>ifconfig eth0 aa.aa.aa.aa netmask bb.bb.bb.bb</pre></blockquote><p>e.g.</p><blockquote><pre>ifconfig eth0 123.45.67.89 netmask 255.255.255.248</pre></blockquote><p>WAN IP address and netmask should be provided by your ISP.</p><p><strong>4.</strong> Set up WAN NIC settings to apply after server start up.</p><p>Configuration files containing NIC settings may have different syntax and location in various distributions. For such distributions as <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.redhat.com"  target="_blank" >RedHat</a>, <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.fedoraproject.com"  target="_blank" >Fedora</a>, <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.centos.org"  target="_blank" >Centos</a> and similar ones <i>eth0</i> configuration file is at <i>/etc/sysconfig/network-scripts/ifcfg-eth0</i>. In <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.debian.org"  target="_blank" >Debian</a>, <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.ubuntu.com"  target="_blank" >Ubuntu</a> NIC settings are located at single file <i>/etc/network/interfaces</i>.</p><p>To edit configuration files use any preferred text editor like <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.vim.org"  target="_blank" >vim</a>, <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.nano-editor.org"  target="_blank" >GNU nano</a> or any other.</p><p>After editing <i>/etc/sysconfig/network-scripts/ifcfg-eth0</i> should look as follows:</p><blockquote><pre>DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=aa.aa.aa.aa        # e.g. 123.45.67.89
NETMASK=bb.bb.bb.bb       # e.g. 255.255.255.0
GATEWAY=ee.ee.ee.ee       # e.g. 123.45.67.1
HWADDR=00:30:4f:3b:af:45  # MAC address (optional entry)
</pre></blockquote><p>After making changes to <i>/etc/network/interfaces</i> section regarding eth0 NIC should looks like:</p><blockquote><pre>auto eth0
iface eth0 inet static
address aa.aa.aa.aa
netmask bb.bb.bb.bb
gateway ee.ee.ee.ee
</pre></blockquote><p>Related links: detailed <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.faqs.org/docs/securing/chap9sec90.html"  target="_blank" >syntax description</a> of <i>/etc/sysconfig/network-scripts/ifcfg-ethN</i>, <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.fifi.org/cgi-bin/man2html/usr/share/man/man5/interfaces.5.gz"  target="_blank" >manual page</a> of <i>/etc/network/interfaces</i>.</p><p><strong>5.</strong> Set up LAN NIC settings to apply after server start up. This step requires operations similar to previous step.</p><p>Edit <i>/etc/sysconfig/network-scripts/ifcfg-eth1</i> and make sure that it looks like:</p><blockquote><pre>DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=cc.cc.cc.cc       # e.g. 192.168.0.1
NETMASK=dd.dd.dd.dd      # e.g. 255.255.255.0
HWADDR=00:50:8d:d1:24:db # MAC address of LAN NIC (optional entry)
</pre></blockquote><p>If you are using Debian or related Linux distribution, edit <i>/etc/network/interfaces</i> (see previous step):</p><blockquote><pre>auto eth1
iface eth1 inet static
address cc.cc.cc.cc
netmask dd.dd.dd.dd
</pre></blockquote><p><strong>6.</strong> Set up Domain Name System servers IP addresses by editing <i>/etc/resolv.conf</i>:</p><blockquote><pre>nameserver 203.145.184.13
nameserver 203.145.184.12
</pre></blockquote><p><strong>7.</strong> Enable IP Forwarding:</p><blockquote><pre>echo 1 &gt; /proc/sys/net/ipv4/ip_forward
</pre></blockquote><p><strong>8.</strong> Set up NAT with iptables:</p><p>To delete existing rules from every iptables table, execute the following commands:</p><blockquote><pre>iptables -F
iptables -t nat -F
iptables -t mangle -F
</pre></blockquote><p>Related links: official iptables <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.netfilter.org/documentation/"  target="_blank" >documentation</a>.</p><p>Enable NAT by commands:</p><blockquote><pre>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
</pre></blockquote><p><strong>8.</strong> Configure LAN clients to access Internet via described gateway:</p><p>Use clients&rsquo; operating system tools to set up the following TCP/IP settings:</p><p>IP address: from the same network as cc.cc.cc.cc (you can use <a
rel="nofollow" href="http://www.nerdgrind.com/goto/http://www.bctes.com/online-ip-subnet-calculators.html"  target="_blank" >IP/Subnet calculator</a> to get it)<br
/>Netmask: dd.dd.dd.dd<br
/>DNS: ff.ff.ff.ff<br
/>Gateway: cc.cc.cc.cc</p><p>Example:</p><blockquote><pre>IP address: 192.168.0.7
Netmask: 255.255.255.0
DNS: 209.160.67.13
Gateway: 192.168.0.1
</pre></blockquote><p>Setting all this up can be a lot easier if you&rsquo;re using a control panel rather than the command line, but I&rsquo;ll save that for another article.</p><p><b>&copy; Copyright <a
href="http://www.nerdgrind.com/" >NerdGrind</a> 2009. All Rights Reserved.</b></p><p><h4>Related posts:</h4><ul
class="st-related-posts"><li><a
href="http://www.nerdgrind.com/how-to-increase-screen-size-or-resolution-in-virtualbox-for-ubuntu-or-linux/" title="How to Increase Screen Size or Resolution in Virtualbox for Ubuntu or Linux">How to Increase Screen Size or Resolution in Virtualbox for Ubuntu or Linux</a></li><li><a
href="http://www.nerdgrind.com/samsung-unveils-flexible-oled-concept-phone-video/" title="Samsung Unveils Flexible OLED Concept Phone &#8211; Video">Samsung Unveils Flexible OLED Concept Phone &#8211; Video</a></li><li><a
href="http://www.nerdgrind.com/prada-announces-prada-ii-phone-will-accompany-bluetooth-watch/" title="Prada Announces Prada II Phone Will Accompany Bluetooth Watch">Prada Announces Prada II Phone Will Accompany Bluetooth Watch</a></li><li><a
href="http://www.nerdgrind.com/fcc-documents-announce-that-nokia-n85-coming-to-north-america/" title="FCC Documents Announce that Nokia N85 Coming to North America">FCC Documents Announce that Nokia N85 Coming to North America</a></li><li><a
href="http://www.nerdgrind.com/casio-81-megapixel-w63ca-480-x-800-pixel-oled-only-in-japan/" title="Casio 8.1 Megapixel W63CA &#8211; 480 x 800 Pixel OLED &#8211; Only in Japan">Casio 8.1 Megapixel W63CA &#8211; 480 x 800 Pixel OLED &#8211; Only in Japan</a></li></ul>]]></content:encoded> <wfw:commentRss>http://www.nerdgrind.com/set-up-nat-with-linux-and-iptables-firewall/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss><!--
This site's performance optimized by W3 Total Cache:

W3 Total Cache improves the user experience of your blog by caching
frequent operations, reducing the weight of various files and providing
transparent content delivery network integration.

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 21/35 queries in 0.155 seconds using memcached

Served from: carsndealerships.com @ 2009-11-21 15:13:27 -->