how to forward wlan0 to eth0?

10,180

Solution 1

You can enable routing. Run this as root

 echo 1 > /proc/sys/net/ipv4/ip_forward

Give manual ip addresses to both ethernet ports, the wireless-connected laptop's IP address becomes the "gateway IP" for the other one. make sure they have the same subnet masks. and the kernel would do the remaining magic.

Solution 2

Sounds like you want to bridge the connections. Depending on your distribution there is a "right" way to configure this such that it will come up on every boot.

Quick and dirty at the command-line, though:

brctl addbr br0
brctl addif br0 eth0
brctl addif br0 wlan0

More info: http://www.linuxfoundation.org/en/Net:Bridge

Not all wireless cards will work with this. Your wireless NIC needs to allow its sending MAC address to be "forged". Your mileage may vary.

If you want to keep communicating from the computer with the wireless NIC in it you're probably going to have to assign an IP address to the bridge, either statically or with DHCP. I don't recall exactly how Linux bridging works and I don't have a box handy.

Edit: I can't tell you if that card will work or not. Give it a try and see. If it doesn't, to kill the bridge do a:

brctl delbr br0
Share:
10,180

Related videos on Youtube

jbunch
Author by

jbunch

Updated on September 17, 2022

Comments

  • jbunch
    jbunch almost 2 years

    I get internet from my wireless wlan0 and I would like to forward it to eth0 which is connected to another laptop. How can I do that? Thanks.

    Edit: my wireless card is intel:

    0b:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)

  • jbunch
    jbunch almost 15 years
    I tried that but it cut off my wireless connection.
  • MarkR
    MarkR almost 15 years
    Bridging will only work if the wireless interface is in master or wds mode, not if it's in "managed" or "adhoc". Wifi essentially "abuses" the ethernet mac addresses as its own addresses, so you can't use it transparently as a bridge (that's what WDS mode is for). This is a feature.
  • Spence
    Spence almost 15 years
    Hmm... Sounds like I'm off-base then. (I thought I recollected that some wireless NICs supported forging their MAC address.) I'm assuming that putting the NIC into AP mode would work, too, but I doubt that most wireless chipsets in PCs support AP mode.
  • jbunch
    jbunch almost 15 years
    tried setting my card to master or WSD but I get that: # iwconfig wlan0 mode master Error for wireless request "Set Mode" (8B06) : SET failed on device wlan0 ; Invalid argument.