[LINUX] [Note] Use a wired LAN connection device with WiFi-Eth bridge on Raspberry Pi 4B

Like this

Internet <=> [Router WifiAP] <~~~> [(wlan0) RPi (eth0)] <=> [Wired LAN Device(Wired LAN connection device)]

Overview

--I want to use a wired LAN connection device in a room where only wireless LAN can be used. ――It's like Internet sharing in Windows, but Raspberry Pi doesn't become a DHCP server, but gets an IP from the original DHCP server. Subnet is not split either.

TL;DR

  1. Burn Raspbian (2020-02-13-raspbian-buster-lite) to microSD.

  2. Download and unzip the zip file (mt08-rpibridge-20200416-1.zip) To do -- rpibridge.sh: Configuration script --ssh: Allow ssh login --wpa_supplicant.conf: <= Edit SSID and password. In some places,country =

    ```bash:wpa_supplicant.conf
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=JP
    network={
            ssid="---SSID---"
            psk="---password---"
    }
    ```
    
  3. Copy the three ↑ to the drive (FAT32) where the files can be seen from Windows on the microSD.

  4. Insert it into the Raspberry Pi and start it. (The configuration file should connect to Wifi)

  5. Login with ssh (default password is raspberry)
    ssh [email protected]

  6. Execute ↓ to download, set, and reboot what you need.
    sudo /boot/rpibridge.sh

  7. Above

environment

--Raspberry Pi 4B
(I think it works with 3B / 3B + / 2B and USB Wifi dongle, but I wonder if the performance is good.)


--Internet environment --The DHCP server is not RPi (eg wireless AP router provides DHCP service) - RPi Wifi(wlan0) --Connected to wireless AP and obtained IP by DHCP (example: 192.168.1.5/24) - RPi Ethernet(eth0) --IP is set with the same netmask / 32 (eg 192.168.1.5/32) assigned to wlan0

Relation

-[Note] WiFi-Eth bridge AP on Raspberry Pi 3 https://qiita.com/mt08/items/8eca5e2535abce9297a4

Other

――If you need it -(TODO) Write a performance measurement with iperf -(TODO) Write an explanation -(TODO) Is it a photo?

The contents of the script

rpibridge.sh


#!/usr/bin/env bash

set -e
[ $(id -u) -ne 0 ] && echo "try: sudo $0" >&2 && exit 1


apt-get update && apt-get install -y parprouted dhcp-helper
grep '^denyinterfaces eth0' /etc/dhcpcd.conf || echo denyinterfaces eth0 | tee -a /etc/dhcpcd.conf 
sed -i -e 's/^#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf

systemctl stop dhcp-helper
systemctl enable dhcp-helper
echo DHCPHELPER_OPTS=\"-b wlan0\" | tee /etc/default/dhcp-helper

# Avahi: enable-reflector=yes
sed -i -e 's/^#enable-reflector=no/enable-reflector=yes/' /etc/avahi/avahi-daemon.conf

cat <<'EOF' >/etc/systemd/system/parprouted.service
[Unit]
Description=proxy arp routing service
Documentation=https://qiita.com/mt08/items/00102a6d513194ea5a92
After=dhcpcd.service

[Service]
Type=forking
# Restart until wlan0 gained carrier
Restart=on-failure
RestartSec=5
TimeoutStartSec=30
ExecStartPre=/bin/echo 'parprouted: wlan0 is online'
# clone the dhcp-allocated IP to eth0 so dhcp-helper will relay for the correct subnet
ExecStartPre=/sbin/ip addr flush dev eth0
ExecStartPre=/bin/bash -c '/sbin/ip addr add $(/sbin/ip -4 addr show wlan0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+\/")32 dev eth0'
ExecStartPre=/sbin/ip link set dev eth0 up
ExecStartPre=/sbin/ip link set wlan0 promisc on

#         v minus sign
ExecStart=-/usr/sbin/parprouted eth0 wlan0

ExecStopPost=/sbin/ip link set wlan0 promisc off
ExecStopPost=/sbin/ip link set dev eth0 down
ExecStopPost=/sbin/ip addr flush dev eth0

[Install]
WantedBy=multi-user.target
EOF
systemctl enable parprouted.service

systemctl daemon-reload
reboot

Recommended Posts

[Note] Use a wired LAN connection device with WiFi-Eth bridge on Raspberry Pi 4B
Run LEDmatrix interactively with Raspberry Pi 3B + on Slackbot
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Use NeoPixel on Raspberry Pi
[Note] Installing vmware ESXi on Arm Fling on Raspberry Pi 4B
getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python
Control the motor with a motor driver using python on Raspberry Pi 3!
Use vl53l0x with Raspberry Pi (python)
A note on what you did to use Flycheck with Python
Turn Raspberry Pi into a router (Wake on LAN [4] over NAT)
[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
Using a webcam with Raspberry Pi
A memo to simply use the illuminance sensor TSL2561 with Raspberry Pi 2
Detect analog signals with A / D converter using python on Raspberry Pi 3!
Use python on Raspberry Pi 3 to light the LED with switch control!
Make a wireless LAN Ethernet converter and simple router with Raspberry Pi
Create a Python multi-user platform with JupyterHub + JupyterLab on Rapsberry Pi 3B +!
USB boot on Raspberry Pi 4 Model B
Build a Tensorflow environment with Raspberry Pi [2020]
Programming normally with Node-RED programming on Raspberry Pi 3
Use the Grove sensor on the Raspberry Pi
Working with sensors on Mathematica on Raspberry Pi
Use PIR motion sensor with raspberry Pi
A note on enabling PostgreSQL with Django
Make a wash-drying timer with a Raspberry Pi
Build OpenCV-Python environment on Raspberry Pi B +
Operate an oscilloscope with a Raspberry Pi
Create a car meter with raspberry pi
Working with GPS on Raspberry Pi 3 Python
Make a thermometer with Raspberry Pi and make it visible on the browser Part 3
Why detectMultiScale () is slow on Raspberry Pi B +
Build a Django environment on Raspberry Pi (MySQL)
Try using a QR code on a Raspberry Pi
Enjoy electronic work with GPIO on Raspberry Pi
Power on / off your PC with raspberry pi
Use Majoca Iris elongated LCD with Raspberry Pi
Use Grove-Temperature & Humidity Sensor (DHT11) on Raspberry Pi
Play with your Ubuntu desktop on your Raspberry Pi 4
Introduced Ceph on Kubernetes on Raspberry Pi 4B (ARM64)
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Control music playback on a smartphone connected to Raspberry Pi 3 and bluetooth with AVRCP
Build a server on Linux and local network with Raspberry Pi NextCloud and desktop sharing
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a web server --3. Use MySQL
Record temperature and humidity with systemd on Raspberry Pi
Try debugging Python on Raspberry Pi with Visual Studio.
Control brushless motors with GPIOs on Raspberry Pi Zero
USB boot with Raspberry Pi 4 Model B (3) LVM edition
A note on speeding up Python code with Numba
Troubleshoot with installing OpenCV on Raspberry Pi and capturing
A memorandum when making a surveillance camera with Raspberry Pi
Make a note of what you want to do in the future with Raspberry Pi
A story about trying to use cron on a Raspberry Pi and getting stuck in space