Configuring OpenWRT as Ad-Hoc modem-like device

Hello folks,

for academic purposes, I want to configure devices with OpenWRT (e.g. Raspberry Pi, as well as dedicated routers) as modem-like devices to be connected to my end user devices.

The topology looks as follows, whereas PC_N describes the end user device and OM_N describes the OpenWRT "modem":

PC_1 ( <--Ethernet --> (eth0: IP_1_e) OM_1 (wlan0: IP_1_w) < - - - (Ad-Hoc WiFi) - - - > shared medium

PC_2 ( <--Ethernet --> (eth0: IP_2_e) OM_1 (wlan0: IP_2_w) < - - - (Ad-Hoc WiFi) - - - > shared medium

PC_1 ( <--Ethernet --> (eth0: IP_3_e) OM_1 (wlan0: IP_3_w) < - - - (Ad-Hoc WiFi) - - - > shared medium

So in general, each PC_N is cable-connected to OM_N and this in turn is connected to an ad-hoc wifi.

Now here is my scenario:

  1. I am running IP-based routing on PC_N. Thus there will be routing decisions like " via" --> If possible, I'd like to ignore IP_N_e + IP_N_w as far as possible.
  2. On OM_N device, I more or less want to pass packets from eth0 to wlan0 and vice versa without modifying the layer 2 ethernet frames (especially the source and destination MAC there) --> I already tried relayd, but this leads to changed MAC fields. Basically, I need a layer 2 solution here.
  3. In the Ad-hoc WiFi, I just need to be able to reach other PC_N in direct reach ("one-hop"), as the routing will take place IP-based on PC_N. Thus, I don't need/want 802.11s/batman_adv/... to make the routing decisions.

Does anyone have a clue on this? Especially on point 2?

Thank you very much in advance!

Your desired configuration is not difficult to achieve, and requires few changes to OpenWRT to get working.

Your magic search terms are "bridge" and "repeater" and similar. The OpenWRT documentation has detailed instructions to achieve what you're asking.

1 Like

I already tried a lot, unfortunately.

For example in the basic configuration, I simply add both interfaces to the same firewall zone (e.g. lan) and allow forwarding.

As a result, if I connect PC_1 <-- Ethernet --> OM_1 <-- WLAN --> Home Router, I get an internet connection over "Ethernet" on PC_1. That's what most repeater, bridge, etc. posts aim for.

But If I ping for instance, in the response (tcpdump or wireshark), the source field in the ethernet frame is the MAC address of OM_1.

The desired behavior in this case would be, that the source field is the one of my home router (which is the case when the packet arrives at wlan0 of OM_1).
I need this for the reason, that I do some MAC filtering on PC_N.

If it's still that simple to solve, I assume the fault is at my side and thank you very much for your participation and an example config to help me out :slight_smile:

The firewall doesn't have any effect on this since it is simple layer 2 switching. Create a kernel bridge and place the Ethernet port in it. It is also necessary to have a network of proto none to actually instantiate the bridge and allow wifi to attach to it.

config device
    option type 'bridge'
    option name 'br-adhoc'
    list ports 'eth0'

config interface 'adhoc'
    option device 'br-adhoc'
    option proto 'none'

Then in /etc/config/wireless, use option network adhoc to attach the interface to the bridge. brctl show should show the result.
Of course this doesn't leave any way to log into the router, that should be on a different interface or you can assign an IP to the bridged interface.


That'll rewrite the MAC address, which your original post said you're trying to avoid.

If I've correctly understood your original problem description, you want to bridge the interfaces. That should preserve L2 contiguity.

Thank you for your reply.
I've tried this, but now all I get is a ARP request on the eth0 of my first device. My overall setup looks like this:
PC_1 ( <-- Ethernet --> OM_1 <-- WiFi --> OM_2 <-- Ethernet --> PC_2 (

These are my configs on OM_1/OM_2 at the moment:


config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr ''
        option netmask ''

config device
        option name 'br-adhoc'
        option type 'bridge'
        list ports 'eth0'

config interface 'lan'
        option device 'br-adhoc'
        option proto 'static'
        option ipaddr ''
        option netmask ''

config interface 'adhoc'
        option device 'br-adhoc'
        option proto 'none'


config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/ahb/18100000.wmac'
        option band '2g'
        option htmode 'HT40'
        option channel '6'

option wifi-iface 'adhoc_wifi'
        option device 'radio0'
        option mode 'adhoc'   
        option network 'adhoc'
        option ssid 'MySSID'   
        option encryption 'none'

With iw dev I can confirm that my WiFi is on the channel 6 in 2.4 GHz band.
brctl show gives me:

bridge name	bridge id		STP enabled	interfaces
br-adhoc		7fff.<MAC>	no		eth0

So when I try to ping PC_2 from PC_1, and check on OM_1, I see:

$ tcpdump -i br-adhoc 
... Many ARP requests: Who has Tell ....


$ tcpdump -i wlan0 
... Nothing here ....

What am I missing?

The addition of the wireless interface to the LAN bridge. Your bridge currently has one interface member: eth0.

Okay maybe we found where my misunderstanding is going to :see_no_evil:

How can I add the wireless interface to the bridge?
I thought this was done by specifying the network option in /etc/config/wireless

No, the bridge is configured in /etc/config/network.

/etc/config/wireless contains the wireless configuration, but does not define how that wireless configuration interacts with the rest of the device.

You can also configure a bridge in LuCI, in Network -> Interfaces -> Devices. You should see the existing bridge there and it should be straightforward to edit the bridge to include the wireless interface. You can then inspect /etc/config/network to see the effect of your change.

Yes, I have been to that point already.

So when I check in LuCI under Network -> Interfaces -> Devices -> br-adhoc -> Configure..., I can only see eth0 as option under Bridge Ports.

Aditionally, it says:

Specifies the wired ports to attach to this bridge. In order to attach wireless networks, choose the associated interface as network in the wireless settings.

That's why I thought the network option in /etc/config/wireless would be the right option to choose.

One moment. Let me double-check on my MT300N. I might have overlooked something.

Yes. I had overlooked something. Made a bit of a category error. Apologies.

Looking at my MT300N running 22.03.5, the bridge includes the wired interfaces, and is assigned to the lan network. In turn, the wireless adapter is also assigned to the lan network. So the wired/wireless bridge isn't blindingly explicit; it's implicit. And that was my error. (I have a vague recollection of earlier incarnations of OpenWRT using an explicit wired\wireless bridge configuration, but it's entirely possible I'm thinking of another routing product entirely...)

As for administering OpenWRT over the lan interface, I recommend one of two approaches:

  • Set option proto 'dhcp' and remove option netmask so that OpenWRT picks up a valid address in your LAN, including an upstream default gateway as well as DNS.
  • Set option ipaddr 'x.x.x.x' to a valid fixed IP address in your LAN, and separately configure a default route and DNS (assuming you want OpenWRT to be able to talk to the Internet; if you don't, and want only local communication, then an IP address is all you need).

Okay, but starting from my configuration in my previous post, I changed the ip of the lan interface:

config interface 'lan'
        option device 'br-adhoc'
        option proto 'static'
        option ipaddr '' # some unused ip from my net
        option netmask ''

and changed the network option

option wifi-iface 'adhoc_wifi'
        option device 'radio0'
        option mode 'adhoc'   
        option network 'lan' # was adhoc previously
        option ssid 'MySSID'   
        option encryption 'none'

That's all you meant, right?

It is still not working as intendet :confused:
Messages are still not passed to my adhoc-wifi.

I know it's possible to achieve; several years ago I used to do exactly this, using a Buffalo WZR-HP-G300NH. I set the thing up as a "dumb AP" for seamless communication between wired and wireless devices without needing to involve any routing.

Admittedly, "several years ago" means that OpenWRT has gone through a few changes since then, and the method I can't quite remember might need adapting for the current version of the product.

To be able to answer further, I'd need to fish out a pair of spare gizmos I can use to recreate what your setup appears to be. Then, if I can get it working, I can answer with hard evidence rather than half-remembered speculation.

Gonna have to cry uncle on this one. I'm baffled.

I fished out my spare GL.iNet GL-MT300N, GL.iNet GL-MT300N-V2, and VoCore VoCore2, put 22.03.5 on all of them, and reset them all to factory defaults.

I disabled the DHCP server on all of them, and gave the lan interface on each of them a different static IP address in the same subnet (I picked as that was in the OP's examples). I attached a computer to each device, using its Ethernet socket, and configured each computer with a unique IP address in the same subnet. Each computer could thus communicate (Ping/SSH/HTTP) with its directly-attached OpenWRT device.

I added an Ad-Hoc wireless connection on each OpenWRT device, using the default OpenWRT SSID without any encryption.

Each device reported seeing other registered stations with that SSID, but I could not for the life of me get each router to send any traffic to the others. Nor could I get each computer to send traffic successfully across the Ad-Hoc wireless link.

Wireshark/tcpdump showed the expected ARP packets as each device attempted to resolve the MAC address of the target IP address on the other side of the wireless link, but without any successful responses.

Evidently assigning the wireless interface to the LAN isn't sufficient on its own to permit ARP broadcasts to traverse the wireless link.

My immediate hunch is there's a gap in my knowledge, that it ought to be possible if only I knew more.

My next hunch is that it might require some sort of overlay, e.g. batman or some other encapsulation feature, to achieve the goal. And if so, then I'm back to the gap in my knowledge; I would have to research such avenues first.

I even set up one device as 'ap' and the other two as 'sta', to see if that might work, but without success.

I just wanted to update this issue. Did you make any progress in the meantime?
Unfortunately, I didn't :frowning: