View Single Post

  #1 (permalink)  
Old 03-23-2008
Tomás Ó hÉilidhe
 
Posts: n/a
Default Achieving what's done by Microsoft's "Internet Connection Sharing"

Before I begin, I'm not looking to turn a PC into a router (as can be
done with specialised Linux distros). I have a normal PC for everyday
use and I want to have the added ability of routing a connection thru
my NIC's.

I have two NIC's. One is wired, the other is wireless. Their names are
eth0 and wlan0 respectively.

I want to set up a virtual router between eth0 and wlan0. For
instance, let's say I have the following setup:

eth0: 192.168.1.1/24
wlan0: 10.10.10.1/24

If eth0 recieves a packet with an IP address different than its own,
then it should send it out unaltered on wlan0. Similarly, if wlan0
receives a packet with an IP address different than its own, it should
send it out unaltered on wlan0. This would be the most basic two-port
router.

I'd like to get that up and running first, and then I'd like to
experiment with a few more stuff:

With packets arriving at eth0, I'd like the router to perform "source
NAT" so that the packets forwarded out on wlan0 have a source IP
address of 10.10.10.1 rather than the actual originating IP address
(in exactly the same way your home broadband router works). In this
setup, there's no need for 10.10.10.1 to be set as a gateway on any
machine.

And lastly, I'd like to have a DHCP server on eth0. Altogether this
would enable me to do the following:

* Using my own computer, connect to an AP normally with my wlan0.
* Take a friend's laptop, connect it to mine via a cross-over cable.
* The DHCP server should give my friend's laptop an IP address, and it
should give it a default gateway of 192.168.1.1 (i.e. the IP address
of eth0)
* When my friend's laptop sends packets to the internet, my virtual
router should perform NAT. And when packets come back from the
internet, my virtual router should keep track of which host they've to
be forwarded to.

Under Microsoft Windows, this can all be done very simply by going
into the settings for wlan0 and clicking "Share this internet
connection". From there, you select a NIC thru which the connection
will be shared, e.g. eth0. And it all works perfectly.

I'm very interested in Linux, and I *do* want to learn about iptables
and dhcpd and so forth, but right now I'm just looking for a quick fix
so that I can get a little network up and running here at home.
Basically I'm looking for the most simplistic config files that will
achieve what I'm trying to do. Does anyone have config files that will
simulate Microsoft's connection sharing? Or perhaps could you guide me
thru what I've to do? So far, it looks like I've to do the following:

* Use iptables to make eth0 act as a gateway thru to wlan0.
* Use iptables to enable "source NAT" for packets coming from eth0
into wlan0.
* Use dhcpd to set up a DHCP server on eth0.

Any advice appreciated!
Reply With Quote