OpenWrt Kamikaze Wi-Fi/Ethernet bridging with parprouted

I’ve got some spare ADM5120 boards with 1 ethernet port and 1 miniPCI slot.

I tried to build an Ethernet/Wi-Fi bridge box, but I were a little disappointed when i found out that the bridge package didn’t work with my Atheros AR5414 based miniPCI Wi-Fi card set in sta (managed) mode. Why? I don’t know!
Both eth0 and wlan0 enters promiscuous mode, but packets aren’t forwarded.

In old Whiterussian release, you just had to put your Wi-Fi interface in wet mode, bridge it with your ethernet interface(s) and everything worked out-of-the-box.
Unluky me… Kamikaze seems to have lost this wonderful option!

So, after an afternoon spent googling, I found parprouted: just what I needed.  The man page states: “parprouted is a daemon for transparent IP (Layer 3) proxy ARP bridging“. Seems complicated, uh?! Anyway, it just fakes ARP replies on both interfaces acting as a proxy for the hosts’ ARP request on both sides of the bridged lan. Just like a hacker’s man in the middle attack.

To install parprouted, you may have to rebuild and reflash your OpenWrt image if your router hasn’t opkg. That’s my case, since my board only has 2MB of flash and I removed it to free up space.
Anyway, I’ll explain both ways (rebuild or opkg), since it’s very simple.

Requirements

  • Average Linux knowledge (Advanced for building your own firmware)
  • vi editor familiarity

Rebuild your OpenWRT with parprouted

To make your firmware image include parprouted package, cd to your OpenWrt compiling folder and follow the instructions:

cd openwrt/8.09/
./scripts/feeds update
./scripts/feeds install parprouted
make menuconfig

Now, under Network section, choose to add parprouted in your image: highlight it and press space bar twice. An asterisk will appear as confirmation. If you don’t need it you can remove bridge package under Base system menu. Now build the image:

make world

And flash the resulting file. Now skip “Install parprouted using opkg” and goto configuration!

Install parprouted using opkg

Make sure you have free space on flash (around 10KB for parprouted and 100KB for opkg operations) and type this on your opkg-enabled router:

opkg update
opkg install parprouted

Configuring Network

Before we begin, I have to explain you what parprouted needs.
First, one of the two bridged interfaces must have a valid ip from your lan addressing space and a valid gateway (and dns, if you want your box to resolve domain names). I chose wlan0 and assigned it the following configuration:

IP Addr 192.168.  1.200
Netmask 255.255.255.  0
Gateway 192.168.  1.  1
DNS     192.168.  1.  1

Then, we have to assign a fake IP to the other interface. In my case eth0, and this is its configuration:

IP Addr 192.168.100.  1
Netmask 255.255.255.  0

Now we have to edit /etc/config/network . Change option ifname entries according to your interface names (see ifconfig output).
Using vi, edit your file to make it look like this:

root@OpenWrt:~# cat /etc/config/network

config 'interface' 'loopback'
 option 'ifname' 'lo'
 option 'proto' 'static'
 option 'ipaddr' '127.0.0.1'
 option 'netmask' '255.0.0.0'

config 'interface' 'wlan'
 option 'ifname' 'wlan0'
 option 'proto' 'static'
 option 'netmask' '255.255.255.0'
 option 'dns' '192.168.1.1'
 option 'gateway' '192.168.1.1'
 option 'ipaddr' '192.168.1.200'

config 'interface' 'lan'
 option 'ifname' 'eth0'
 option 'proto' 'static'
 option netmask '255.255.255.0'
 option dns ''
 option gateway ''
 option ipaddr '192.168.100.1'

Configuring Wireless

If you are unsure about how to edit this file values, you can check wireless section of LuCI Reference (see Reference #1, bottom of the post).
Your /etc/config/wireless should look like this (edit wireless network parameters according to your AP settings, note that option type entry depends on your wireless driver, so don’t touch it):

root@OpenWrt:~# cat /etc/config/wireless
config wifi-device  wlan0
 option type     mac80211

 option disabled 0

config wifi-iface
 option device    wlan0
 option network    wlan
 option mode    sta
 option ssid    YOUR_SSID
 option encryption YOUR_ENCRYPTION
 option key    YOUR_KEY

Configuring parprouted daemon

Edit /etc/default/parprouted and put into OPTIONS variable the name of the two interfaces you want to bridge, separated by a blank space. You can find your interfaces names in ifconfig output.

root@OpenWrt:~# cat /etc/default/parprouted
OPTIONS=”eth0 wlan0″

Done. Reboot and your box should act as a Wi-Fi client bridge!

References

  1. LuCI Reference
  2. parprouted on freshmeat.net

Tags: , ,

Rispondi

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.