0

So I want to setup a network bridge between my ethernet connection and the wlan adapter such that the raspberry 3 acts as a device where my chromecast can connect to and shares the internet connection over ethernet, where the raspberry pi is connected to a router.

There are tons of instructions out there to do this, but I need a static IP on my ethernet connection, which then should be shared to the chromecast that is connected via wlan to my raspberry. Is that possible?

I tried to follow the instructions here: https://wiki.debian.org/BridgeNetworkConnections#Manual_bridge_setup but now my raspberry does not conenct to the internet anymore properly.

And also from the last section here: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

I hope someone can help me, here are my files:

cat /etc/os-release

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

/etc/network/interfaces (here the last part that is uncommented I though is what needs to be done, but it makes the raspberry not connect to the internet anymore, so I commented it out.)

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
#source-directory /etc/network/interfaces.d


# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface

auto eth0
iface eth0 inet static
        address 128.131.60.73
        netmask 255.255.252.0
    gateway 128.131.60.1
        dns-nameservers 128.130.4.3 128.131.4.3


# WLAN
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wireless-power off


# Netzwerkbrücke
#auto br0
#iface br0 inet static
#        address 128.131.60.73
#        netmask 255.255.252.0
#        gateway 128.131.60.1
#        dns-nameservers 128.130.4.3 128.131.4.3

#bridge_ports eth0 wlan0

/etc/dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private


denyinterfaces wlan0
denyinterfaces eth0

/etc/hostapd/hostapd.conf

interface=wlan0
bridge=br0
#driver=nl80211
ssid=WLANPi
hw_mode=a
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
1

The problem is that the Raspberry Pi Foundation does not show in its example Setting up a Raspberry Pi as an access point in a standalone network (NAT) how to configure a static ip address to the bridge. You can use Setting up a Raspberry Pi as an access point - the easy way if you like. Just go direct to the section Setting up an access point with a bridge and follow it. I have added four lines in /etc/systemd/network/12-br0_up.network to fit your needs by setting static ip addresses.

With old style networking you setup interfaces in one file /etc/network/interfaces. With systemd you do not have one file, instead you use a file for each interface in directory /etc/systemd/network. In the example eth0 is set with /etc/systemd/network/04-br0_add-eth0.network. Look at the Name= under [Match]. As member of a bridge it does not need any ip address because a bridge works only with mac addresses. Instead the ip address is given to the bridge br0.

  • Thanks! What I wonder is: where do I set up the ethernet connectio, with systemd?, or am I just not? – wa4557 Nov 22 '18 at 7:16
  • @wa4557 I have updated my answer. – Ingo Nov 22 '18 at 9:49
  • Great it almost works except that I cannot connect to the WLAN with my smartphone. It always hangs with "IP-address is retrieved", so it sets up the bridge (i.e. I can connect to the pi through ssh) but I still cannot connect to it with my mobile phone... I suspect it has to do with the static IP of the bridge? – wa4557 Nov 22 '18 at 10:34
  • @wa4557 No, the static ip address on the bridge doesn't matter. It has nothing to do with the bridge. It is only to address the RasPi itself. Seems the mobile phone uses DHCP as usual. The bridge also bridges DHCP requests to the internet router. You have to ensure that it has a DHCP server enabled that give ip addresses to the connected devices. – Ingo Nov 22 '18 at 10:56
  • Ah I think I understand. What if my router does not have DHCP server implemented? Can I fake that somehow with the RPI? (Since I want it to just give it the same IP as the ethernet connection) – wa4557 Nov 22 '18 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.