<?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>Some stuff &#187; eth</title>
	<atom:link href="http://blog.yhuang.org/?feed=rss2&#038;tag=eth" rel="self" type="application/rss+xml" />
	<link>https://blog.yhuang.org</link>
	<description>here.</description>
	<lastBuildDate>Wed, 27 Aug 2025 08:50:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>connection sharing on linux</title>
		<link>https://blog.yhuang.org/?p=774</link>
		<comments>https://blog.yhuang.org/?p=774#comments</comments>
		<pubDate>Mon, 05 Dec 2011 18:50:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[conf]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[Edit]]></category>
		<category><![CDATA[eth]]></category>
		<category><![CDATA[init]]></category>

		<guid isPermaLink="false">http://scripts.mit.edu/~zong/wpress/?p=774</guid>
		<description><![CDATA[To turn a linux box with two network interfaces into a NAT router with the most basic functions, four separate changes are required. This is more complicated than it needs to be. For future reference: 1. Enable packet forwarding in the &#8220;registry&#8221;: Edit /etc/sysctl.conf to add net/ipv4/ip_forward=1 then > sysctl -p /etc/sysctl.conf 2. Set address [...]]]></description>
			<content:encoded><![CDATA[<p>To turn a linux box with two network interfaces into a NAT router with the most basic functions, four separate changes are required. This is more complicated than it needs to be. For future reference:</p>
<p>1. Enable packet forwarding in the &#8220;registry&#8221;:<br />
Edit <em>/etc/sysctl.conf</em> to add<br />
<em>net/ipv4/ip_forward=1</em> then<br />
> <em>sysctl -p /etc/sysctl.conf</em></p>
<p>2. Set address sharing for outbound traffic and poke holes in the firewall:<br />
Assume eth0 is the WAN-facing interface and eth1 is the LAN-facing interface, then<br />
> <em>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</em><br />
> <em>iptables -t filter -A FORWARD -i eth1 -o eth0 -j ACCEPT</em><br />
> <em>iptables -t filter -A FORWARD -i eth0 -o eth1 -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT</em><br />
> <em>/etc/init.d/iptables save active</em><br />
> <em>/etc/init.d/iptables restart</em><br />
Turn on the iptables service in <em>sysvconfig</em></p>
<p>3. Enable automatic serving of dynamic LAN IP&#8217;s:<br />
Assume 10.0.0.x is the LAN-side subnet and 192.168.0.1 is the WAN-side DNS server or gateway, then<br />
Edit <em>/etc/dhcp3/dhcpd.conf</em> to add, e.g.<br />
<em>subnet 10.0.0.0 netmask 255.255.255.0 {<br />
&nbsp;&nbsp;&nbsp;&nbsp; range 10.0.0.2 10.0.0.10;<br />
&nbsp;&nbsp;&nbsp;&nbsp; option routers 10.0.0.1;<br />
&nbsp;&nbsp;&nbsp;&nbsp; option domain-name-servers 192.168.0.1<br />
}</em><br />
> <em>/etc/init.d/dhcp3-server restart</em></p>
<p>4. Set the LAN-facing interface to be on the LAN-side subnet:<br />
Assume 10.0.0.1 is the LAN-side address of connection sharing machine, then<br />
Edit <em>/etc/network/interfaces</em> to add<br />
<em>auto eth1<br />
iface eth1 inet static<br />
&nbsp;&nbsp;&nbsp;&nbsp; address 10.0.0.1<br />
&nbsp;&nbsp;&nbsp;&nbsp; netmask 255.255.255.0<br />
&nbsp;&nbsp;&nbsp;&nbsp; gateway 192.168.0.1</em><br />
> <em>/etc/init.d/networking restart</em></p>
]]></content:encoded>
			<wfw:commentRss>https://blog.yhuang.org/?feed=rss2&#038;p=774</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
