Like this
Internet <=> [Router WifiAP] <~~~> [(wlan0) RPi (eth0)] <=> [Wired LAN Device(Wired LAN connection device)]
--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
Burn Raspbian (2020-02-13-raspbian-buster-lite
) to microSD.
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---"
}
```
Copy the three ↑ to the drive (FAT32) where the files can be seen from Windows on the microSD.
Insert it into the Raspberry Pi and start it. (The configuration file should connect to Wifi)
Login with ssh (default password is raspberry
) ssh [email protected]
Execute ↓ to download, set, and reboot what you need.
sudo /boot/rpibridge.sh
Above
--Raspberry Pi 4B
(I think it works with 3B / 3B + / 2B and USB Wifi dongle, but I wonder if the performance is good.)
2020-02-13-raspbian-buster-lite
--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
-[Note] WiFi-Eth bridge AP on Raspberry Pi 3 https://qiita.com/mt08/items/8eca5e2535abce9297a4
――If you need it -(TODO) Write a performance measurement with iperf -(TODO) Write an explanation -(TODO) Is it a photo?
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