Is it possible to use Linux for a Wireless Bridge? You bet! Last night one of our USB wireless adapters kicked the bucket. Being down one, I decided to see if I could come up with a creative solution rather than plunk down another $20 that I may or may not have right now. One of the things in my inventory is a Linux laptop (Remember Project 50/50?) that has no problem connecting to my WiFi.
I suspected that there would be a way to route Ethernet traffic from my desktop PC (running Windows 7) through the Ethernet on the laptop, and through its WiFi connection. The laptop already has CrunchBang Linux running on it (a Debian derivative.) Thanks to IPTables, this was a simple task.
First, I ran an Ethernet cable between the Ethernet port on my desktop PC and the laptop. Because of Modern Technology I didn’t even have to use a crossover cable. I configured the PC with the IP of 192.168.2.2, Subnet Mask 255.255.255.0, Gateway of 192.168.1.1 and DNS of 184.108.40.206 and 220.127.116.11.
Then, with the WiFi already connected via the Linux GUI, I ran the following shell script as root:
ifconfig eth0 up ifconfig eth0 192.168.2.1 echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.2.0/24 -j MASQUERADE
Voila! We have a bridged connection. The only trouble was that Network-Manager kept putting eth0 down because it was not configured. This was solved by running
and then selecting “Wired conneciton 1” and then “Edit…” and then unchecking “Connect Automatically.” This solved that problem.
Since this is only a temporary solution, I haven’t set it up to automatically do the routing every time the system boots. But, it works for now and is a simple, elegant solution. Plus it saved me $20!
I hope this works well for you. If you have any questions, please don’t hesitate to comment below! 🙂