Gert
Posts: 226
Joined: Wed Oct 24, 2012 10:19 pm

Static IP for bridge interface in RPI access point

Thu Sep 22, 2022 6:15 pm

Hello all,

I'm using this instructable from the docs to setup my RPI as bridged wireless AP.
https://www.raspberrypi.com/documentati ... cess-point

My topology:

Code: Select all

Router:----ethcable----RPI4 ))) wifi ((( ESP32 device
|
+---ethcable---PC1
The AP works fine (tested with laptop on new assigned SSID)

But I can no longer access the RPI via the static IP that I have assigned to the eth0 interface.
After some searching I found the RPI at a DHCP assigned IP of the br0 interface.

Do I assume correctly that the eth0 IP address is occupied by the bridge? See line in dhcpcd.conf.

Code: Select all

denyinterfaces wlan0 eth0
Why is access to eth0 denied? Could it not serve both purposes for bridge and my network access at the same time?

As a solution is it OK to ask for a static IP for the br0 interface? Does it follow the same syntax in dhcpcd.conf ??

For just now I use IP assignment by MAC in the router to prev used IP address. I have other RPI on the network that want access to that address for other services.

Cheers,
Gert

epoch1970
Posts: 8063
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Static IP for bridge interface in RPI access point

Thu Sep 22, 2022 9:25 pm

There is an official guide here: https://www.raspberrypi.com/documentati ... cess-point
It should answer a few of your questions.

Instead of having just

Code: Select all

interface br0
in dhcpcd.conf, which calls for DHCP configuration, have the static config of your choice

Code: Select all

interface br0 
 static ip_address=…
…
Of course reserving an IP address in the DHCP server would be preferable to static config. That’s one of the reasons why the guide is written as it is.

Usually, IP reservation in DHCP servers is based on the MAC address of the client. On Linux, a bridge by default adopts the lowest MAC address among the interfaces connected to the bridge. There is a chance the bridge does always adopt the MAC of eth0 if the address is smaller than the address of wlan0.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Gert
Posts: 226
Joined: Wed Oct 24, 2012 10:19 pm

Re: Static IP for bridge interface in RPI access point

Thu Sep 22, 2022 9:55 pm

Hi,

I was quoting the instructable that I used.
https://www.raspberrypi.com/documentati ... cess-point

Question:
Why is eth0 denied ? I expect the network connection to the router to be still available for connection from other computer

Code: Select all


denyinterfaces wlan0 eth0

For access to the PI the IP that is static to the eth0 no longer works from other computer.

As workaround I can assign the same IP to br0 either via static IP or MAC address in the router.

But I prefer solution to keep eth0 available.

dhcpcd.conf (part thereof)

Code: Select all

....
denyinterfaces wlan0 eth0

# Example static IP configuration:
interface eth0
static ip_address=192.168.11.182/24
static routers=192.168.11.1
static domain_name_servers=8.8.8.8 75.75.75.75

# For bridged wireless access point
interface br0
ifconfig:

Code: Select all

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.11.182  netmask 255.255.255.0  broadcast 192.168.11.255
        inet6 fe80::6ec9:c9ca:bfee:5e49  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:21:56:5f  txqueuelen 1000  (Ethernet)
        RX packets 752061  bytes 42141934 (40.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 120029  bytes 2197568181 (2.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::dea6:32ff:fe21:565f  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:21:56:5f  txqueuelen 1000  (Ethernet)
        RX packets 757190  bytes 56541501 (53.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1553789  bytes 2292265181 (2.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 6349  bytes 560716 (547.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6349  bytes 560716 (547.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::dea6:32ff:fe21:5660  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:21:56:60  txqueuelen 1000  (Ethernet)
        RX packets 2520  bytes 511415 (499.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33191  bytes 8525453 (8.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Cheers,
Gert

User avatar
procount
Posts: 2705
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Static IP for bridge interface in RPI access point

Fri Sep 23, 2022 8:30 am

I think you are missing the distinction between a BRIDGE and a ROUTER, which was explained by someone in your previous post.

In a router, eth0 and wlan0 have separate IP address because they are on different network segments. You need a router to transfer messages from one segment to another.

A Bridge joins the 2 networks together so they act as one. You don't need a router function to pass messages from eth0 to wlan0, they flow automatically because they are on the same network.

So in a bridge, eth0 & wlan0 do not have separate IP addresses. The bridge br0 is assigned the IP address which is shared between eth0 and wlan0. So you can access the RPi using the same IP from the wlan0 network side, or the eth0 network side.
(This is a simplistic explanation)
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

epoch1970
Posts: 8063
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: Static IP for bridge interface in RPI access point

Fri Sep 23, 2022 9:19 am

Gert wrote:
Thu Sep 22, 2022 9:55 pm
I was quoting the instructable that I used.
https://www.raspberrypi.com/documentati ... cess-point
Sorry, I didn't realise that was called an instructable. My spellchecker doesn't seem to think that is a common word.

Anyway, to the question about eth0 being denied, and the answer in the thing itself (emphasis mine):
https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-bridged-wireless-access-point wrote:Define the bridge device IP configuration

Network interfaces that are members of a bridge device are never assigned an IP address, since they communicate via the bridge. The bridge device itself needs an IP address, so that you can reach your Raspberry Pi on the network.

dhcpcd, the DHCP client on the Raspberry Pi, automatically requests an IP address for every active interface. So we need to block the eth0 and wlan0 interfaces from being processed, and let dhcpcd configure only br0 via DHCP.


If connection fails, something is wrong with your setup. Check again your config files.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Gert
Posts: 226
Joined: Wed Oct 24, 2012 10:19 pm

Re: Static IP for bridge interface in RPI access point

Fri Sep 23, 2022 8:56 pm

Hello All,
epoch1970 wrote:
Fri Sep 23, 2022 9:19 am
...

Network interfaces that are members of a bridge device are never assigned an IP address, since they communicate via the bridge. The bridge device itself needs an IP address, so that you can reach your Raspberry Pi on the network.

dhcpcd, the DHCP client on the Raspberry Pi, automatically requests an IP address for every active interface. So we need to block the eth0 and wlan0 interfaces from being processed, and let dhcpcd configure only br0 via DHCP.

Please confirm is my understanding is right/wrong.

The 'bridge apparatus' is comprised of eth0 (network-side) wan0 (wifi side).
The assignment of the interfaces to the same duty makes them unusable for anything else.
A new interface br0 is created out of thin air for the purpose of accessing the 'bridge apparatus' from the wired network.
I notice that eth0 and br0 have the same MAC. See above post ipconfig report. So yet there are the same physical interface. (there is only one network socket at the RPI) As it is the same connector why is such an effort made to create 2 logical interfaces for it? What about the wlan0? Is it possible to connect to the RPI again on wlan?

For the moment let's assume the creation of the br0 interface is necessary. Why isn't the br0 assigned to the 'bridge apparatus' and eth0 is left the same as before?

Is that something I can change myself?
1. assigning br0 to the 'bridge apparatus'
2.keeping eth0 and assigned static IP the same?

Cheers,
Gert

User avatar
rpdom
Posts: 20561
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Static IP for bridge interface in RPI access point

Fri Sep 23, 2022 9:29 pm

A bridge is a way of combining physical interfaces together so they appear as one interface. Traffic can pass through the bridge from one interface to another.

The physical interfaces no longer have individual IP addresses. Instead they all share the Bridge IP.

You can pretty much forget about accessing eth0 or wlan0. Just use br0 and traffic will go out through the appropriate physical interface depending on the destination.
Unreadable squiggle

redvli
Posts: 145
Joined: Thu Sep 03, 2020 8:09 am

Re: Static IP for bridge interface in RPI access point

Sat Sep 24, 2022 5:57 am

Maybe another way of looking at this is https://en.wikipedia.org/wiki/OSI_model

'bridge' operates in Layer2, is using physical hardware/drivers for ethernet chip and wifi chip. It can only send and receive data packages to the 'other end of the cable'. It provides services to the higher layer (Layer3 = IP stack). In theory, you could also assign IP addresses to eth0 and wlan0 besides to br0. But then the IP stack (Layer3) would then also be able to the same thing the bridge already does (but on a higher layer, with more overhead). So '2 captains on the same ship', which normally won't work. You then would have to disable the bridge completely, then it works, but then it is 'routing' and then you need and have different IP networks for the wired and wireless parts.

You can set a different MAC address for br0 then the default one for eth0, but it is not needed. I have done it for a Pi that is Wifi accesspoint and uses dynamic IP address (from from DHCP server in router). But disadvantage is, is that when you boot the Pi with another OS or SDcard or remove access point functionality, the MAC address that the Pi send to the router in its DHCP request is then different ( the default one again). So it is more convenient to have MAC address of eth0 and br0 the same (in case of dynamic IP address obtained from the router).

Gert
Posts: 226
Joined: Wed Oct 24, 2012 10:19 pm

Re: Static IP for bridge interface in RPI access point

Sat Sep 24, 2022 7:57 pm

Hello All,

Thank you for the clarification on bridge interface behavior. I guess my question was mainly academic.
The bridge functionality works fine for me. The little wifi ESP32 talks with my network. (The main wifi router is too far away for the built-in antenna of the device)

I cleaned up the dhcpcd.conf. remove unnecessary stuff from eth0 and set static IP for br0.

/etc/dhcpcd.conf (part)

Code: Select all

...
# For bridged wireless access point
denyinterfaces wlan0 eth0

# eth0 used for wifi bridge
interface eth0

# wlan0 used for wifi bridge
interface wlan0

# New br0 network access to bridged wireless access point
interface br0
static ip_address=192.168.11.182/24
static routers=192.168.11.1
static domain_name_servers=8.8.8.8 75.75.75.75
As the functionality is stable we can close the thread.

Thanks,
Gert

Return to “Networking and servers”