Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to be able to connect a desktop computer that does not have a wireless adapter to my wireless network.

I could just run a network cable from my ADSL/wireless router to the desktop computer but sometimes this is not practical.

What I would really like to do is bridge my laptop's wireless and wired adapters in such a way that I can run a network cable from my laptop to a switch and another network cable from the switch to a desktop computer so that the desktop computer can access the Internet through my ADSL/wireless router via my latop:

+--------------------+
|ADSL/wireless router|
+--------------------+
    |
+-------------------------+
|laptop's wireless adaptor|
|                         |
|laptop's wired adaptor   |
+-------------------------+
    |
+------+
|switch|
+------+
    |
+-----------------------+
|desktop's wired adapter|
+-----------------------+

A bit of Googling suggests that I can do this by bridging my laptop's wireless and wired adapters.

In Windows XP's Network Connections I select both the Local Area Connection and the Wireless Network Connection, right click and select Bridge Connections.

From what I gather, this (layer 2?) bridge will examine the MAC address of traffic coming from the wireless network and pass it through to the wired network if it suspects that a network adapter with that MAC address may be on the wired side, and vice-versa.

If this is the case, I would assume that when the desktop computer attempts to get an IP address from a DHCP server (which is running on the ADSL/wireless router), it would send a DHCP broadcast packet which would pass through the laptop's bridge to the router and the reply would return through the laptop's bridge back to the desktop.

This doesn't happen.

With some more Googling I find some instruction how this can be done with Linux. I reboot to Ubuntu 9.10 and type the following:

sudo apt-get install bridge-utils
sudo brctl addbr br0
sudo brctl addif br0 wlan0
sudo brctl addif br0 eth0
sudo ipconfig wlan0 0.0.0.0
sudo ipconfig eth0 0.0.0.0

Once again, the desktop cannot reach the ADSL/wireless router.

I suspect that I'm missing some simple important step. Can anyone shed some light on this for me?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I have decided to use NAT on my Ubuntu laptop instead of bridging which works well except for not being able to use my router's DHCP server. I may well install a DHCP server on my laptop if I can't be bothered manually configuring my desktop's network. Regardless, this is how I did the wireless to wired NAT...

My router's (and therefore my laptops wireless connection's) network is 192.168.1.0, I will use 192.168.0.0 for the network on my laptop's eth0 interface and the desktop.

To start with I turn of the Network Manager by right clicking on the network icon in the system tray and remove the tick from Enable Networking.

I create a file called /etc/wpa_supplicant.conf (as root) containing the following:

ctrl_interface=/var/run/wpa_supplicant
network={
    ssid="myssid"
    scan_ssid=1
    key_mgmt=WPA-PSK
    psk="mypresharedkey"
}

Where "myssid" is my router's SSID and "mypresharedkey" is my router's WPA pre shared key.

I then fire up my wireless networking with:

sudo iwconfig wlan0 essid myssid
sudo wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B

And obtain on IP address, nameserver and default gateway with:

sudo dhclient wlan0

That's the first part done. Now I need to get NAT working so traffic for eth0 can get to/from the router.

First I need to tell Ubuntu that I want to allow forwarding:

sudo bash
echo 1 > /proc/sys/net/ipv4/ip_forward
exit

I would have thought I could have echoed 1 to /proc/sys/net/ipv4/ip_forward using sudo but for some reason I always get a permission denied message, so I sudo bash and echo 1 from a root shell.

Then I set up some forwarding rules:

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

And finally set up the LAN port, eth0:

sudo ifconfig eth0 192.168.0.254

All done on my laptop, now to get desktop's network configured:

sudo ifconfig eth0 192.168.0.1
sudo route add default gw 192.168.0.254
sudo bash
echo "nameserver 192.168.1.254" > /etc/resolv.conf
exit

Once again, I don't seem to be able to use echo to write a file unless I sudo bash first.

And that's it. I can now access the Internet from my desktop, through my laptop's wireless connection.

share|improve this answer

I would prefer to get the bridge working under Ubuntu so I'm still searching for answers, but I was able to get the bridge to work on Windows XP.

After bridging the Local Area Connection and the Wireless Network Connection I opened a command prompt and typed the following:

netsh bridge show a

This listed my Local Area Connection with an ID of 1 and my Wireless Network Connection with an ID of 2. The ForceCompatibilityMode of my Wireless Network Connection was shown as Unknown so I typed the following:

netsh bridge set a 2 e

This enabled my Wireless Network Connection. The desktop computer was able to get itself an IP address from the DHCP server on the router. As it turned out, the IP address that it got was the same as the IP address that my Wireless Network Connection usually gets which caused Windows to complain of an IP address conflict on the network. I gave my desktop computer a static IP address and all was well. The desktop computer and the laptop can now both use the Internet.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.