AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 3:15 am

Found the source of the issue, there was " nterface=wlan0" not "interface=wlan0" in /etc/hostapd/hostapd.conf. Probably missed the "i" when was copying - pasting.

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 2:51 pm

Bridge seems to be working now but I have IP assigning issues as soon as I disconnect from the router. I want Pi to assign IP addresses from 192.168.0.xxx subnet for both eth0 and wlan0 clients.
I tried 'static' options for all eth0 wlan0 and br0 in /etc/network/interfaces but it did not do the trick. I guess the static option is more for a client after all. I need something like broadcast but wasn't able to find such option in man pages. Any ideas ?

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 3:37 pm

You have a choice.

You can disable the dhcp server in your router (not recommended) and install dnsmasq using br0 as the dhcp interface. You must install a static ip on br0.

Or you can use the routing/ mSquerade version of the AP install.

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 3:45 pm

SurferTim wrote:
Mon Sep 25, 2017 3:37 pm
Or you can use the routing/ mSquerade version of the AP install.
I would definitely go with that option. Where can I find a tutorial on it? There seems to be only one guide on setting up a wireless hotspot on raspberrypi.org

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 4:01 pm

I just edited and submitted the change on that tutorial for APs, but it is.being tech checked. Look on this topic for the /configuration/wireless/access point.md not working thread.

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 4:12 pm

SurferTim wrote:
Mon Sep 25, 2017 4:01 pm
I just edited and submitted the change on that tutorial for APs, but it is.being tech checked. Look on this topic for the /configuration/wireless/access point.md not working thread.
I think I found them:
viewtopic.php?t=193943#p1214847

I will give them a try later today. Thanks SurferTim!

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 4:18 pm

I guess I leave the changes about br0 in /etc/network/interfaces and delete the line about denying wlan0 and eth0 from/etc/network/dhcpcd.conf , correct ?

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 6:55 pm

Nope. You should remove:
the addition to /etc/network/interfaces,
the denyinterfaces line from /etc/dhcpcd.conf
eth0 from the bridge

Code: Select all

sudo brctl delif br0 eth0
and change /etc/hostapd/hostapd.conf from the interface=br0 to driver.

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 10:40 pm

SurferTim wrote:
Mon Sep 25, 2017 6:55 pm
Nope. You should remove:
the addition to /etc/network/interfaces,
the denyinterfaces line from /etc/dhcpcd.conf
eth0 from the bridge

Code: Select all

sudo brctl delif br0 eth0
and change /etc/hostapd/hostapd.conf from the interface=br0 to driver.

I have done all the recommended steps and my Pi working as a wireless AP now and assigning IPs to wi-fi clients but the bridge to eth0 isn't working anymore. Even though I assigned a static IP from 192.168.0.xxx subnet to eth0 in /etc/dhcpcd.conf clients on wlan0 can't reach the ones on eth0 and vice versa....

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 10:42 pm

Read my response on the other thread. Stick to one or the other. Don't double post.

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 10:58 pm

SurferTim wrote:
Mon Sep 25, 2017 10:42 pm
Read my response on the other thread. Stick to one or the other. Don't double post.
Sorry I replied in the other thread by mistake.
That is correct. You have a choice:
1) A bridge, which allow bidirectional client access.
2) An AP router, which allows only unidirectional access (wlan0 to eth0 only).

It sounds like you want a bridge with a dhcp server so the dhcp server works with or without the gateway router. You can assign a localnet IP to the bridge, and use dnsmasq to assign dhcp settings to both sides of the bridge, but you must disable the dhcp server on your gateway router to use this effectively. The localnet will not work without the RPi bridge operational. That is the tradeoff.
Basically I am trying to make a standalone network consisting of wireless and wired networks managed by Pi. By managing I mean assigning IP addresses from the same subnet.

I was thinking of keeping a working connection to the router to update the system once in a while but if that complicates the setup too much I can leave without that.

Also if wireless clients have to go static IP I can work with it too.

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Mon Sep 25, 2017 11:46 pm

Before you break your internet connection, install dnsmasq.

Code: Select all

sudo apt-get install dnsmasq
Get the bridge br0 working per the instructions, and add this to /etc/dhcpcd.conf

Code: Select all

interface br0
static ip_address=192.168.4.1/24
Move the original dnsmasq.conf

Code: Select all

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Open a new dnsmasq.conf.

Code: Select all

sudo nano /etc/dnsmasq.conf
and add this:

Code: Select all

interface=br0
dhcp-range=192.168.4.20,192.168.4.100,255.255.255.0,12h
Insure there is no router (dhcp server) on the localnets.
Reboot. Disconnect and reconnect your localnet computers to the network.
All your wlan and eth devices should show an IP between 192.168.4.20 and 192.168.4.100.
No internet connection though.

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Tue Sep 26, 2017 5:01 am

I restored Raspbian from an image I created before changing any network configuration.
Then I did all these:
Install dnsmasq.

Code: Select all

sudo apt-get install dnsmasq
Get the bridge br0 working per the instructions:
install hostapd and bridge utilities.

Code: Select all

sudo apt-get install hostapd bridge-utils
sudo systemctl stop hostapd
Create bridge br0.

Code: Select all

sudo brctl addbr br0
Create file /etc/hostapd/hostapd.conf

Code: Select all

interface=wlan0
bridge=br0
#driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit /etc/default/hostapd, uncomment and change this:

Code: Select all

DAEMON_CONF="/etc/hostapd/hostapd.conf"
Add eth0 to br0

Code: Select all

sudo brctl addif br0 eth0
Edit /etc/network interfaces and add this

Code: Select all

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
Edit /etc/dhcpcd.conf and add this above other interfaces

Code: Select all

denyinterfaces eth0 wlan0
reboot

and add this to /etc/dhcpcd.conf

Code: Select all

interface br0
static ip_address=192.168.0.1/24
Move the original dnsmasq.conf

Code: Select all

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Open a new dnsmasq.conf.

Code: Select all

sudo nano /etc/dnsmasq.conf
and add this:

Code: Select all

interface=br0
dhcp-range=192.168.0.20,192.168.0.50,255.255.255.0,24h
Insure there is no router (dhcp server) on the localnets.
Reboot. Disconnect and reconnect your localnet computers to the network.
All your wlan and eth devices should show an IP between 192.168.0.20 and 192.168.0.50.
No internet connection though.
RPiNet is up but I can't connect to it "Failed to obtain IP address"

If I switch the client (phone) to static IP e.g. 192.168.0.4 I can connect to RPiNet and even can access a client from the eth0 (I can ping and open embedded webserver 192.168.0.222). However I cannot access the very client 192.168.0.222 from the actual Raspberry Pi (no ping and can't open the webpage)
There is no IP address shown at any interfaces per ifconfig.
Bridge is active (running) and it contains both eth0 and wlan0
One weird thing I noticed is that systemd-hostnamed.service takes about a minute on startup.

If I go to /etc/network/interfaces and change from

Code: Select all

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
to

Code: Select all

auto br0
iface br0 inet static
    address 192.168.0.1
    netmask 255.255.255.0
    network 192.168.0.0
bridge_ports eth0 wlan0
then I can connect to RPiNet from the phone without changing to static IP. RPi assings an IP from the range 20-50 which is expected.
ifconfig shows br0 at 192.168.0.1 but there is no IP shown for any other interfaces.
I can ping the phone from the Pi and the other way around but I cannot access the client from eth0 (192.168.0.222)
I am not able to talk to the 192.168.0.222 from the Pi either.
systemd-hostnamed.service does not cause any delay on startup anymore.

I tried adding static IP for eth0 and wlan0 in /etc/network/interfaces but it did not change anything.

Did I miss something important?

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Tue Sep 26, 2017 10:34 am

Change this

Code: Select all

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
to this

Code: Select all

auto br0
iface br0 inet manual
bridge_ports eth0 wlan0
This has been changed in my latest tutorial submission.

Static network setting assignments are done in /etc/dhcpcd.conf.

The new document update submission for wifi access points can be found here:
https://github.com/SurferTim/documentat ... s-point.md

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Tue Sep 26, 2017 1:24 pm

SurferTim wrote:
Tue Sep 26, 2017 10:34 am
Change this

Code: Select all

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
to this

Code: Select all

auto br0
iface br0 inet manual
bridge_ports eth0 wlan0
This has been changed in my latest tutorial submission.

Static network setting assignments are done in /etc/dhcpcd.conf.

The new document update submission for wifi access points can be found here:
https://github.com/SurferTim/documentat ... s-point.md
Thank you SurferTim for your help again. I just changed br0 mode to manual. Raspberry Pi assigns IP to wireless clients as expected now but I still can't access 192.168.0.222 which is on eth0.

I just read your guide on github and noticed that I missed routing and masquerade part. Do I need it for my setup? I thought it is required for a configuration without the bridge. Am I correct?
I also noticed that the guide says 'dhcp' for br0 in /etc/network/interfaces. Is it a mistake? Do you want me to submit a pull request on It?

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Bridge wlan0 and eth0 - help needed

Tue Sep 26, 2017 1:34 pm

It has already been changed. Did that yesterday. It doesn't show up on that link.

I'm getting the impression that is why the official documentation is out of date. By the time they "tech check" it, and edit it, the info on that page will be obsolete.

Try this link
https://github.com/SurferTim/documentat ... s-point.md

AndriusWild
Posts: 30
Joined: Thu Sep 21, 2017 9:10 pm

Re: Bridge wlan0 and eth0 - help needed

Tue Sep 26, 2017 5:13 pm

I finally got my network working.
It turned out the issues I had with the client 192.168.0.222 were caused by "DHCP and Static" setting on the client.
Since Pi acts as DHCP server it changed the default address 192.168.0.222 to 192.168.0.214 after plugging the device in the network and I did not notice that. I switched the device to fully static IP mode and that solved the problem.
Special thanks to SurferTim for the amazing tech support! :!: :) :) :)
Here is all the steps I did:
-----------------------------------------------------------------------------------
Created: 2017-09-26
Raspbian Stretch Release 2.1 - September 2017
------------------------------------------------------------------------------------

Install the following packages before your break your internet connection:

Code: Select all

sudo apt-get install dnsmasq hostapd bridge-utils
Stop the services:

Code: Select all

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd
Create bridge br0:

Code: Select all

sudo brctl addbr br0
Create file /etc/hostapd/hostapd.conf

Code: Select all

interface=wlan0
bridge=br0
#driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit /etc/default/hostapd, uncomment and change this:

Code: Select all

DAEMON_CONF="/etc/hostapd/hostapd.conf"
Add eth0 to br0:

Code: Select all

sudo brctl addif br0 eth0
Edit /etc/network/interfaces and add this:

Code: Select all

auto br0
iface br0 inet manual
bridge_ports eth0 wlan0
Edit /etc/dhcpcd.conf and add this above other interfaces:

Code: Select all

denyinterfaces eth0 wlan0
Reboot then add this to /etc/dhcpcd.conf

Code: Select all

interface br0
static ip_address=192.168.0.1/24
Move the original dnsmasq.conf

Code: Select all

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Open a new dnsmasq.conf

Code: Select all

sudo nano /etc/dnsmasq.conf
and add this:

Code: Select all

interface=br0
dhcp-range=192.168.0.20,192.168.0.50,255.255.255.0,24h
Start the services:

Code: Select all

sudo service hostapd start  
sudo service dnsmasq start
Add routing and masquerade

Edit /etc/sysctl.conf and uncomment this line:

Code: Select all

net.ipv4.ip_forward=1
Add a masquerade for outbound traffic on eth0:

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o eth0 -j MASQUERADE
Save the iptables rule:

Code: Select all

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Edit /etc/rc.local and add this just above "exit 0" to install these rules on boot:

Code: Select all

iptables-restore < /etc/iptables.ipv4.nat
Insure there is no router (dhcp server) on the localnets.
Reboot. Disconnect and reconnect your localnet computers to the network.
All your wlan and eth devices should show an IP between 192.168.0.20 and 192.168.0.50.
No internet connection though.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Tue Jan 16, 2018 5:26 pm

@SurferTim
I've been reading through this thread and am halfway through the process.
I have TWO WiFi. wlan0 and wlan1. wlan1 is a dongle while wlan0 is the built in Pi WiFi.
Currently wlan1 is broadcast as an AP and I can connect quite nicely to it.

Before I keep moving here is my ucase.
The Pi will be working standalone in the field and will need to be connected to via WiFi by a client. Great. Got that working.
But, sometimes we will want the user to connect to the internet via wlan0 or GSM in order to:
* Get updates which will be done via a service to be run looking for an internet connection
* Download maps and other resources as needed
* Provide a mechnism to allow the client to get through a captive portal (this is where we thought of bridging) To allow user to connect to captive portal and get the web page usually associated with it to their browser either on their tablet, lappie, or cell phone.

Given these scenarios, my question is:
Is bridging the recommended way or is there a better method?

Thanks a mil!

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Tue Jan 16, 2018 6:24 pm

If you mean wlan1 is the AP and wlan0 is a client, then use the standalone (NAT) access point. I have not found a way to add a client wlan to a bridge. It throws an "operation not permitted" error.

Near the end of the instructions, you should add a MASQUERADE for any client interfaces, like wlan0 in you case. Add it just like you would for eth0.

pertm84
Posts: 13
Joined: Sat Oct 20, 2018 10:59 am
Location: Norway

Re: Bridge wlan0 and eth0 - help needed

Sat Oct 20, 2018 11:05 am

Hello,

I have my pi setup with an ip/mac binding in my router at the address 192.168.1.xxx. This way I dont have to set a static ip on my pi each time i edit some settings.

I followed your guide step-by-step and it is working. I can connect my phone to RpiNet and access the internet.
This means that the wifi bridge to eth0 i working.

However, now I cannot SSH into my pi with ssh [email protected]

Any ideas how I can solve this?



SurferTim wrote:
Fri Sep 22, 2017 1:33 pm
This is the setup I use with Stretch. This is the only time I recommend adding anything to /etc/network/interfaces.

Code: Select all

sudo apt-get update
sudo apt-get upgrade
install hostapd and bridge utilities.

Code: Select all

sudo apt-get install hostapd bridge-utils
sudo systemctl stop hostapd
Create bridge br0.

Code: Select all

sudo brctl addbr br0
Create file /etc/hostapd/hostapd.conf

Code: Select all

interface=wlan0
bridge=br0
#driver=nl80211
ssid=RPiNet
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit /etc/default/hostapd, uncomment and change this:

Code: Select all

DAEMON_CONF="/etc/hostapd/hostapd.conf"
Add eth0 to br0

Code: Select all

sudo brctl addif br0 eth0
Edit /etc/network interfaces and add this

Code: Select all

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
Edit /etc/dhcpcd.conf and add this above other interfaces

Code: Select all

denyinterfaces eth0 wlan0
reboot

Edit: Don't panic if you get a double red x on the network icon in the upper right corner of the GUI desktop. That is to be expected. Also, you will get a red "failed" message on boot for the dhcpcd service. That is also expected.

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Sat Oct 20, 2018 12:23 pm

I don't have a problem using ssh on a bridge.

Run ifconfig and insure the IP is assigned to br0, and both eth0 and wlan0 have no assignments.

Edit: Also use this. Note "manual", not "dhcp"

Code: Select all

auto br0
iface br0 inet manual
bridge_ports eth0 wlan0

pertm84
Posts: 13
Joined: Sat Oct 20, 2018 10:59 am
Location: Norway

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Sat Oct 20, 2018 2:44 pm

SurferTim wrote:
Sat Oct 20, 2018 12:23 pm
I don't have a problem using ssh on a bridge.

Run ifconfig and insure the IP is assigned to br0, and both eth0 and wlan0 have no assignments.

Edit: Also use this. Note "manual", not "dhcp"

Code: Select all

auto br0
iface br0 inet manual
bridge_ports eth0 wlan0
Ok, so using ifconfig:

br0 has ip 192.168.1.125,
the et0 and wlan0 has no assigned ips.

and the iface br0 inet is set to "manual"


I think there must be a typo somewhere:/ Now I have to use VNC to use the terminal through my cellphone

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Sat Oct 20, 2018 3:41 pm

Did you enable ssh in the rpi config? It is disabled by default.

pertm84
Posts: 13
Joined: Sat Oct 20, 2018 10:59 am
Location: Norway

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Mon Oct 22, 2018 9:33 am

SurferTim wrote:
Sat Oct 20, 2018 3:41 pm
Did you enable ssh in the rpi config? It is disabled by default.
I just doublel-checked, and I have it enabled in the Stretch GUI Raspberry configuration, that should suffice yes?
Just tried the ssh-keygen -R 192.168.1.125 but I still get the: ssh: connect to host 192.168.1.125 port 22: Connection refused

EDIT:

I dont have the red-crosses over my wifi arrows as you suggested to the other user. At least I can connect through vnc-viewer and use the terminal on the Pi through there, if you need any logfiles? I attach a picture from when I mouse-over the arrows/network connections on the Pi.

Thank you so much for using your time on this, I really appreciate it!
Attachments
IMG_4968.jpg
IMG_4968.jpg (173.03 KiB) Viewed 156 times

SurferTim
Posts: 1764
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: [SOLVED] Bridge wlan0 and eth0 - help needed

Mon Oct 22, 2018 11:30 am

What is the IP/netmask on the computer that you are using to connect to the RPi?

Edit /etc/sysctl.conf and uncomment

Code: Select all

net.ipv4.ip_forward=1

Return to “Troubleshooting”