promisc 모드에서 ARP 프록시를 사용하여 브리지

promisc 모드에서 ARP 프록시를 사용하여 브리지

편집하다:나는 이것이 다음과 중복된 것을 발견했습니다.네트워크 어댑터가 무차별 모드인 경우에만 ARP 응답이 수행되는 이유는 무엇입니까?.


저는 Rasbian Stretch와 함께 Raspberry Pi 3B+를 사용하고 Debian의 튜토리얼에 따라 프록시 arp로 설정했습니다.프록시 ARP를 사용하여 네트워크 연결 브리징eth0을 wlan0에 "브리지"합니다. 이에 따르면 다음을 사용하여 프록시 arp를 쉽게 설정할 수 있습니다.

rpi3 ~# echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp
rpi3 ~# echo 1 > /proc/sys/net/ipv4/ip_forward
rpi3 ~# ip route add 192.168.10.60/32 dev eth0

192.168.10.60wlan0에 "브리지"되어야 하는 eth0의 클라이언트입니다.

하지만 작동하지 않습니다. 작동하려면 wlan0에서 무차별 모드를 활성화해야 하지만 이를 수행하기 위한 힌트를 찾을 수 없습니다.

rpi3 ~# ip link set wlan0 promisc on

무차별 모드가 필요합니까 Stretch? 그렇지 않다면 어떻게 피할 수 있습니까?

업데이트:
rp_filter0으로 설정되어 있음 을 확인했습니다
hostapd. 설치되지 않았습니다. wlan0은(는) 클라이언트 모드에 있으며 에 의해 관리됩니다 wpa_supplicant.

답변1

분명히 클라이언트 모드의 무선과 이더넷 간에 이더넷 프레임을 브리지하는 것은 불가능합니다. 예를 들어 작동하지 않습니다.

또한 다른 소스의 프레임을 클라이언트로서 AP 인프라에 주입하지 않도록 주의하십시오.

대부분의 액세스 포인트(AP)는 AP로 인증되지 않은 소스 주소가 있는 프레임을 거부합니다.

답변2

Raspberry Pi의 Wi-Fi에서만 문제가 되는 것 같습니다. 또한 중복된 질문네트워크 어댑터가 무차별 모드인 경우에만 ARP 응답이 수행되는 이유는 무엇입니까?라즈베리파이를 사용합니다. 튜토리얼의 다른 어느 곳에서도 프록시 arp에 대해 무차별 모드를 활성화하는 메모를 찾을 수 없습니다. 무차별 모드 없이 프록시 arp가 작동하는 노트북에서 이를 확인했습니다.

이 문제는 RASPBERRY PI FOUNDATION 및/또는 폐쇄 소스 드라이버 제조업체에서만 해결할 수 있다고 생각합니다. 그때까지 우리는 그것과 함께 살아야합니다.

답변3

promisc 모드에서 ARP 프록시를 사용하여 브리지

모든 장치가 네트워크에 있는 경우 WiFi-to-LAN(예: microUSB-LAN 어댑터가 있는 Raspberry Pi Zero W) 연결을 "브리지"할 수 있습니다.동일한 서브넷(IP 범위) 사용ARP 프록시~와 함께약속 모드.

계획:
[라우터] <---WiFi---> [RasPi wlan0 <---브리지---> eth0] <---LAN 케이블---> [유선 장치, 예: 컴퓨터]

힌트:제공되는 솔루션은 이러한 우수한 소스를 기반으로 합니다.
소스 #1파스칼 가이저(Pascal Geiser)
소스 #2윌 헤일리

다음 예에 사용된 하드웨어/OS:
microUSB-LAN 어댑터가 포함된 Raspberry Pi Zero W
Raspbian Stretch Lite(2019-04-08) + 업데이트




솔루션 #1 - 인터페이스를 통한 ARP 프록시(수동 구성)

참고: 이는 WiFi 라우터가 "IP 레이어 3 솔루션"(네트워크 레이어)을 지원하는지 여부에 따라 다릅니다.

1)Raspberry Pi의 라우터에 대한 WiFi 연결이 이미 설정되어 연결되어 있다고 가정합니다.

2)패키지 설치

$ sudo apt-get install parprouted dhcp-helper

삼)다음 줄을 편집하고 추가합니다

.

  • 무선랜0WiFi 카드에 내장된 라즈베리의 ID입니다.
  • eth0유선 이더넷 카드(microUSB-LAN 어댑터)의 ID입니다.
$ sudo nano /etc/network/interfaces
# Clone the dhcp-allocated IP to eth0 so dhcp-helper will relay for the correct subnet
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
  wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  pre-up /sbin/ip link set wlan0 promisc on
  post-down /sbin/ip link set wlan0 promisc off
  post-up /usr/sbin/parprouted eth0 wlan0
  post-down /usr/bin/killall /usr/sbin/parprouted
  post-up /etc/init.d/dhcp-helper restart
  pre-up /sbin/ifup eth0
  post-up /sbin/ip addr add $(/sbin/ip -4 -br addr show wlan0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0
  pre-down /sbin/ip addr del $(/sbin/ip -4 -br addr show wlan0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0
  post-down /sbin/ifdown eth0

# Set ethernet interface to "manual" mode
auto eth0
allow-hotplug eth0
iface eth0 inet manual

4)패킷 전달 활성화:

$ sudo nano /etc/sysctl.conf
# Find and uncomment this line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1
# to -->
net.ipv4.ip_forward=1

5)DHCP 릴레이 구성

DHCP 도우미는 요청을 포착하여 "실제" DHCP 서버로 전달합니다.

$ sudo nano /etc/default/dhcp-helper
# Change eth0 by the name of your wireless interface (e.g. wlan0)
#DHCPHELPER_OPTS="-b eth0"
# to -->
DHCPHELPER_OPTS="-b wlan0"

6)AVAHI 구성

"리플렉터 모드"를 활성화하면 클라이언트가 브리지에 연결된 모든 서비스를 탐색할 수 있습니다.

$ sudo nano /etc/avahi/avahi-daemon.conf
# Find and change the following line
#enable-reflector=no
# to -->
enable-reflector=yes

7)RasPi 재부팅

재부팅 후 eth0 / LAN 연결된 장치를 통해 WiFi 라우터의 동일한 네트워크에 액세스해야 합니다.
참고: 작동하는 솔루션은 WiFi 라우터가 "IP 레이어 3 솔루션"(네트워크 레이어)을 지원하는지 여부에 따라 다릅니다.

$ sudo reboot



솔루션 #2 - 서비스를 통한 ARP 프록시(자동 스크립트 솔루션)

참고: 이는 WiFi 라우터가 "IP 레이어 3 솔루션"(네트워크 레이어)을 지원하는지 여부에 따라 다릅니다.

1)다음 내용으로 bash 스크립트를 만듭니다.

$ sudo nano bridge.sh
#!/usr/bin/env bash

set -e

[ $EUID -ne 0 ] && echo "run as root" >&2 && exit 1

##########################################################
# You should not need to update anything below this line #
##########################################################

# Credits to Will Haley
# Mainly based on source: https://willhaley.com/blog/raspberry-pi-wifi-ethernet-bridge/#option-1---same-subnet
# Edited on line #52 by Tomtom: path to systemd for parprouted.service

# parprouted  - Proxy ARP IP bridging daemon
# dhcp-helper - DHCP/BOOTP relay agent

apt update && apt install -y parprouted dhcp-helper

systemctl stop dhcp-helper
systemctl enable dhcp-helper

# Enable ipv4 forwarding.
sed -i'' s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/ /etc/sysctl.conf

# Service configuration for standard WiFi connection. Connectivity will
# be lost if the username and password are incorrect.
systemctl restart wpa_supplicant.service

# Enable IP forwarding for wlan0 if it's not already enabled.
grep '^option ip-forwarding 1$' /etc/dhcpcd.conf || printf "option ip-forwarding 1\n" >> /etc/dhcpcd.conf

# Disable dhcpcd control of eth0.
grep '^denyinterfaces eth0$' /etc/dhcpcd.conf || printf "denyinterfaces eth0\n" >> /etc/dhcpcd.conf

# Configure dhcp-helper.
cat > /etc/default/dhcp-helper <<EOF
DHCPHELPER_OPTS="-b wlan0"
EOF

# Enable avahi reflector if it's not already enabled.
sed -i'' 's/#enable-reflector=no/enable-reflector=yes/' /etc/avahi/avahi-daemon.conf
grep '^enable-reflector=yes$' /etc/avahi/avahi-daemon.conf || {
  printf "something went wrong...\n\n"
  printf "Manually set 'enable-reflector=yes in /etc/avahi/avahi-daemon.conf'\n"
}

# I have to admit, I do not understand ARP and IP forwarding enough to explain
# exactly what is happening here. I am building off the work of others. In short
# this is a service to forward traffic from WiFi to Ethernet.
#cat <<'EOF' >/usr/lib/systemd/system/parprouted.service
cat <<'EOF' >/etc/systemd/system/parprouted.service
[Unit]
Description=proxy arp routing service
Documentation=https://raspberrypi.stackexchange.com/q/88954/79866
Requires=sys-subsystem-net-devices-wlan0.device dhcpcd.service
After=sys-subsystem-net-devices-wlan0.device dhcpcd.service

[Service]
Type=forking
# Restart until wlan0 gained carrier
Restart=on-failure
RestartSec=5
TimeoutStartSec=30
# clone the dhcp-allocated IP to eth0 so dhcp-helper will relay for the correct subnet
ExecStartPre=/bin/bash -c '/sbin/ip addr add $(/sbin/ip -4 -br 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
ExecStart=-/usr/sbin/parprouted eth0 wlan0
ExecStopPost=/sbin/ip link set wlan0 promisc off
ExecStopPost=/sbin/ip link set dev eth0 down
ExecStopPost=/bin/bash -c '/sbin/ip addr del $(/sbin/ip -4 -br addr show wlan0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0'

[Install]
WantedBy=wpa_supplicant.service
EOF

systemctl daemon-reload
systemctl enable parprouted
systemctl start parprouted dhcp-helper

2)bash 스크립트를 실행합니다(오류가 있는지 출력 확인).

$ sudo bash bridge.sh

삼)RasPi 재부팅

eth0/LAN 연결 장치를 통해 재부팅한 후 WiFi 라우터의 동일한 네트워크에 액세스해야 합니다. 참고: 이는 WiFi 라우터가 "IP 레이어 3 솔루션"을 지원하는지 여부에 따라 다릅니다.

$ sudo reboot



일반 사항:

  • ARP 프록시지원이 필요하다"IP 레이어 3/네트워크 레이어" 기능을 위한 WiFi 라우터(시도해보고 알아낼 수 있을 것 같습니다).
  • 동일한 서브넷에서 브리지 솔루션을 제공하기 위해 WDS를 통한 기본 솔루션(여기서는 해당 주제를 다루지 않음)에는 WiFi 칩의 WDS 지원이 필요합니다.그리고WiFi 라우터. WDS 지원을 위해 Raspberry Pi의 WiFi 칩을 확인할 수 있습니다.
$ iw list

섹션에서지원되는 인터페이스 모드

Wiphy phy0
...
    Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * WDS
         * monitor
         * mesh point
...

만약에WDS~이다따로 기재되어 있지 않음여기에서는 WDS가지원되지 않음WiFi 칩으로(Raspberry Pi Zero W는 WDS를 지원하지 않습니다).

관련 정보