Re: Achieving what's done by Microsoft's "Internet Connection Sharing"



Tomás Ó hÉilidhe wrote:

* 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!

Linux is practically built for the task of being a router. :)

Ofc there could be handy GUI thingies in gnome or kde from which you can
set it up quite easily, but I'm not familiar with those so I'll let
other people elaborate on that subject.

From the console, all you need is two set up ethernet devices, ip
forwarding, a default gateway and iptables.

eth0: 192.168.1.1
wlan0: 10.10.10.1

Routing without nat. Well, that subject only uses the route command.
You just need to tell those networks where they can locate eachother.
(Important to keep in mind, for every route one way, a route back is
needed. It's useless for packets to know where to go, if the packets
that need to go back don't know which way to go.)

$ route add 192.168.1.0/24 gw 192.168.1.1
$ route add 10.10.10/24 gw 10.10.10.1

This tells the box that in order to reach the networks 192.168.1.0 and
10.10.10.0 from localhost, it needs to access those through the
respective gateways 192.168.1.1 and 10.10.10.1.

Ofcourse this will only work if the machines in those networks use that
box as gateway for eiter the destination network, or the default gate.

Make sure ip forwarding is set.

$ sysctl net.ipv4.ip_forward=1

Source routing is quite simple too:

$ iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT -o wlan0
--to-source 10.10.10.1

I did not test these commands, so there might be a typo somewhere. But
this should be the general idea (if I get your question right).

-R-
.



Relevant Pages

  • Re: UDPs sendto() from two IP Addresses to IP Address from small LAN
    ... I fail to see what default route has to do with OP's issue. ... packets to different networks. ... The packets are correctly delivered. ... interfaces because routing table says so, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Routing
    ... When you only brought "eth0" up and were able to reach the ... 192.168.3/24 and 10.1.0/24 networks, what did your routing table look ... default route to a specific gateway machine, ...
    (Debian-User)
  • Re: Cant send packets via WiFi (possibly route issue)
    ... Send all packets to any address 192.168.0.x out on eth0 ... As soon as the first packet got out on the eth1 interface to the first ... NONONONO There can be only ONE default route. ...
    (comp.os.linux.networking)
  • Re: multi-uplink and link state judgement
    ... I want to have a backup route to internet ... In the begining, when both route are good, I can see packets ... coming into linux box from eth0 indeed go out from eth2 route. ...
    (comp.os.linux.networking)
  • Help: Cant Make a Simple iproute2 Configuration to Work
    ... from all iif eth0 lookup 2 ... and I don't want to use the default route with gateway 65.11.15.193. ... I just want all packets ...
    (comp.os.linux.networking)