1

I'm unsure what this is called, but the situation is the following:

I want to have a Raspberry Pi + WiFi USB Module connect to a WiFi network.. then share that connection with another router that is connected via Ethernet.. (A spare DIR-655 to be exact).

Is this a gateway? Do I plug the ethernet into my router's "Internet" Port?

3 Answers 3

4

You're describing a wireless bridge between the RPi's Ethernet and wireless interfaces. Simply using normal Ethernet Layer 2 bridging (e.g. bridge-utils) won't work due to wifi design limitations, however you can achive the same effect via Proxy ARP. Proxy ARP is a routed (Layer 3) solution, but works for all IP traffic: see https://wiki.debian.org/BridgeNetworkConnectionsProxyArp for details, but it is as simple as:

$ sudo apt-get install parprouted dhcp-helper avahi-daemon

Edit /etc/network/interfaces to configure the interfaces:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
  wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  post-up /usr/sbin/parprouted eth0 wlan0
  post-down /usr/bin/killall /usr/sbin/parprouted
  # clone the dhcp-allocated IP to eth0 so dhcp-relay will relay for the correct subnet
  post-up /sbin/ip addr add $(/sbin/ip addr show wlan0 | perl -wne 'm|^\s+inet (.*)/| && print $1')/32 dev eth0
  post-down /sbin/ifdown eth0

Edit /etc/sysctl.d/local.conf to enable IP forwarding:

net.ipv4.ip_forward=1

Enable DHCP relay: /etc/default/dhcp-helper

# relay dhcp requests as broadcast to wlan0
DHCPHELPER_OPTS="-b wlan0"

Edit /etc/avahi/avahi-daemon.conf to enable mDNS relaying:

[reflector]
enable-reflector=yes

Reboot, and hosts connected to the bridge's ethernet should acquire a DHCP address and have full IP connectivity!

You can connect another router to the Pi's Ethernet, in which case you'd very likely want to use that router's WAN port connected to the Pi (dont use the LAN ports - you're likely to end up with duelling DHCP servers at the least). If all you're doing is connecting multiple hosts via the Pi, just use a switch.

5
  • thank you, should I have the wpa-ssid and wpa-psk entries somewhere in there as well? right now they were underneath iface wlan0 inet dhcp
    – Erik
    Aug 16, 2015 at 4:07
  • The wlan interface config should be unchanged, that is the wpa-* items should remain under iface wlan .... In my example I'm using the separate conf file rather than individual wpa-* entries. Once the wifi interface is working, just add the post-up and post-down bits (though the post-down items aren't strictly required to "just make it work"), make the other listed changes, reboot and it should be good to go.
    – Ben
    Aug 18, 2015 at 1:02
  • It's been good to go, got it working! Just wanted to double check my thoughts on those particular params. Thanks again
    – Erik
    Aug 18, 2015 at 6:51
  • You also need to enable poxy_arp in sysctl: net.ipv4.conf.all.proxy_arp=1 Mar 11, 2019 at 18:01
  • And also had to wait before copying ip address of wlan0 to eth0. This is my post-up line: post-up /usr/sbin/parprouted eth0 wlan0 && /bin/sleep 3 && /sbin/ip addr add $(/sbin/ip addr show wlan0 | /usr/bin/perl -wne 'm|^\s+inet (.*)/| && print $1')/32 dev eth0 Mar 11, 2019 at 18:07
1

Yo can use OpenWRT. Connect the raspi to the Wi-Fi network and then, configure eth to give dhcp to the router. You will need to allow "forwarding" between networks in firewall config or just try to "bridge" Wi-Fi and eth if you're getting dhcp from the main wireless router.

Wi-FI Router > Usb Pi > Router Wan. Don't expect to get more than 10Mbps.

Let me know if you need any help.

3
  • Would I load open wrt on the router, the pi, or both? The dir655 doesn't support it.. But I can get another router if needed
    – Erik
    Jul 28, 2015 at 14:12
  • Load OpenWrt to pi. If you can get another router, buy one that could act as a "Client". It will connect to Wi-Fi and give network to lan ports. In specifications look at "Wireless Modes". You need: Bridge with AP/ Client. If you can manage de main router, you only need an access point like TL-WA901ND. If you need more than one rj45 port, use a switch behind the AP. With it, you can use the pi for another project ;-)
    – edumgui
    Jul 29, 2015 at 8:38
  • I went with the debian based solution as it made more utility for the pi overall.. but thank you.
    – Erik
    Aug 18, 2015 at 6:50
0

If understand correctly you're asking for using the raspberry pi a wireless access point, in that case there are many tutorials for you to choose from, e.g:

1
  • No, the pi will consume WiFi... Not serve it.
    – Erik
    Jul 28, 2015 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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