Score:1

Bridging traffic between eth0 and wlan0

cw flag

I have tried with this but can`t get it to work, the eth0 and wlan0 are already up and running so my setup is a lot easier. wlan0 has a DHCP already enabled and is correctly assigning the IP to the client, eth0 is set to static, the client is connecting with a static IP. These are the settings from ifconfig:

eth0 Link encap:Ethernet HWaddr 00:14:3E:9D:BA:57
inet addr:192.168.13.31 Bcast:192.168.13.255 Mask:255.255.255.0
inet6 addr: fe80::214:3eff:fe9d:ba57/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1600 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74056 (72.3 KiB) TX bytes:3936 (3.8 KiB)

wlan0 Link encap:Ethernet HWaddr 64:69:4E:77:D5:2E
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::6669:4eff:fe77:d52e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:618 errors:0 dropped:0 overruns:0 frame:0
TX packets:656 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:72055 (70.3 KiB) TX bytes:87715 (85.6 KiB)

The client connected through wlan0 has IP 192.168.1.11 (dhcp) while the client connected on eth0 has 192.168.13.10 (static). I would like the two to communicate with each other, this below is the setup for the iptables:

sysctl -w net.ipv4.ip_forward=1

iptables --flush
iptables -I INPUT -j ACCEPT
iptables --table nat --flush
iptables --table nat --delete-chain
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o wlan0 -m state --state NEW -j ACCEPT
iptables -A INPUT -m udp -p udp --sport 67:68 --dport 67:68 -j ACCEPT

After this from the shell of the device I can still ping both clients but the client on the eth0 can`t ping the client on the wlan0 and viceversa.

Ron Maupin avatar
us flag
You bridge on the same network and route between networks. You are trying to route on the same network, but you want to use bridging, not routing.
homer69 avatar
cw flag
yes, correct, but when I try to bridge the two networks it will fail giving me an error for nl80211: Failed to add interface wlan0 into bridge br0: Operation not supported. I have been looking into this for quite a while and still can`t figure out why this is not possible to add wlan0 and eth0 to the same br0 interface. So as an alternative I was looking into using the NAT but I am not entirely sure why this is not working and if my setup is not correct.
Nikita Kipriyanov avatar
za flag
**Only** the access point can bridge wireless with wired; wireless client can't do that, this is given by WiFi (802.11) specifications; that's why you weren't able to bridge them. // To have routing, you need, well, correct routes. If you want bidirectional unobstructed communications, dont' use NAT and better flush all the firewall. Machines on wireless should have `192.168.1.1` as the gateway, and wired machines `192.168.13.31` as a gateway. Once all works, you may add rules one by one and observe what happens.
homer69 avatar
cw flag
@NikitaKipriyanov yes the wlan0 is setup as an AP and not client, the problem is that as soon as i run the hostapd with the configuration line: bridge=br0 it will fail with the command not permitted. I would prefer bridging instead of routing because this makes everything simpler.
homer69 avatar
cw flag
@NikitaKipriyanov going back to this, would you be able to give some advise on how to do so? I believe I am falling a little short on knowledge on how this works, the real goal would be to have the same subnet for both wireless and wired and to send the data bidirectionally. wired: 192.168.0.0 wireless: 192.168.0.0 and I would like to ping a client on the wired (192.168.0.141) from a client on the wireless (192.168.0.11), I can't get it to work and I don't understand if the problem is with the route or the iptables, any advise will be much appreciated.
homer69 avatar
cw flag
from the client on the wired interface I can ping the eth0 interface (192.168.0.31) and from the client on the wireless interface I can ping the wlan0 interface (192.168.0.1) but I can`t reach each other. I have tried with the bridging as well, so to add both wlan0 and eth0 to a bridge and then to remove the routes, but I get some odd behavior and I don`t know if this is something I should rather avoid...
Nikita Kipriyanov avatar
za flag
The primary advice is *don't use iptables* at first. Don't try to build everything simultaneously, build in steps. Flush the firewall, let it pass absolutely any traffic so you'll exclude the possible problems with it. When you learn how to set up routing properly you'll be able to build the firewall again.
homer69 avatar
cw flag
I have flushed the firewall, but what command should I use to allow all the traffic through and also to allow the forwarding between the two interfaces? The OS is based on yocto and the previous release I could add both interfaces to a br0 (bridge) and then to remove the routes for eth0 and wlan0, it worked. Now the same steps with the latest release, as soon as the interfaces are added to the bridge I will lose connectivity, I did look into NAT but the real goal would be bridging....
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.