1

this is my first question on this site.

My problem is that i have an old PC lying around with no WiFi adapter but it has an Ethernet adapter.

I want to connect my Raspberry pi to WiFi then connect it with an Ethernet wire to the PC to share internet but how?

My board is Raspberry pi 3 b

zyad ali
  • 11
  • 1
  • Should be possible. It will involve adjusting config settings to bridge the WiFi and Ethernet connections. I’m on my phone at the moment but will try to provide further details later if someone else hasn’t already done so. – Pete Hooper Jun 25 '21 at 21:07
  • Answered here: https://raspberrypi.stackexchange.com/questions/48307/sharing-the-pis-wifi-connection-through-the-ethernet-port – Pete Hooper Jun 25 '21 at 22:39
  • Does this answer your question? [Sharing the Pi's WiFi connection through the Ethernet port](https://raspberrypi.stackexchange.com/questions/48307/sharing-the-pis-wifi-connection-through-the-ethernet-port) – Dougie Jun 26 '21 at 14:17

1 Answers1

2

There are several options to achieve what you want. It depends on your use case. If you do not need to access the PC from a device on your local network then you can use NAT (Network Address Translation) which makes routing configuration simple. Here is an example How to make Raspberry Pi 4 as “WIFI” -> “Ethernet” adaptor without add any USB component?.

If you want to access the PC from a remote device then you have to use static routing. This needs additional configuration of your home hotspot/internet router. Look at this example for it: Direct Ethernet IPCam and Wifi for browsing - Networking setup.

If you want to have the PC on the same subnet of your local network you can use proxy arp. This is the most transparent setup because the PC seems to be just on the local network like any other device but it is also the most sophisticated setup. Have a look at Workaround for a wifi bridge on a Raspberry Pi with proxy arp.

Ingo
  • 40,606
  • 15
  • 76
  • 189
  • Your answers are great, but out of curiosity: Have you ever tried to do this using `brctl` (linux kernel bridge, the userspace command is part of `bridge-utils`)? I've only ever used it with containers (ie., virtual interfaces) but I don't see why it could not be used here, eg.: [How do I configure a network interface bridge from WiFi to Ethernet with Debian?](https://unix.stackexchange.com/a/363347/25985) (may not work as is with Raspbian but configuring this directly in a short script is not hard). – goldilocks Jun 26 '21 at 14:10
  • @goldilocks Of course you can still use `bridge-utils`, `hostapd`, `dnsmasq`, `iptables` (for NAT) and other separate helpers to configure a Linux system. I have also done it before **systemd**. This fulfills the Unix paradigm to combine small and simple different programs to get a complex system. But this paradigm is from a time where no one have thought about parallel computing. This all works only synchronous. But nowadays really every processor comes with more than one core and synchronous execution is supported very badly. – Ingo Jun 27 '21 at 10:21
  • @goldilocks **Systemd** has been introduced since version **Jessie** and they do hard work to make it compatible with old style computing as most as possible otherwise they wouldn't have a chance to become accepted. The result is that parts of systemd is mixed with classic utilities with having old style synchronous working in mind. A typical bad example of this is [Setting up a Raspberry Pi as a bridged wireless access point](https://www.raspberrypi.org/documentation/configuration/wireless/access-point-bridged.md). But with more and more acceptance compatibility will be lost more and more. – Ingo Jun 27 '21 at 10:22
  • @goldilocks So I decided to consequently use only systemd. This is mainly to improve my own experience with modern all day parallel computing but share it with the community. This may not be easy for an experienced Unix user because he has to learn new things. But I am convinced that learning Unix for a newbie is easier with **systemd** because it is consistent managing only one system. Yes, I know the discussion about systemd to be monolithic and violate the Unix paradigm but I think that is the price we have to pay to follow parallel computing evolution. – Ingo Jun 27 '21 at 10:22
  • Hmm, for one, I'm not sure how parallel vs. synchronous really matters here, and two, I doubt very much whatever systemd does is particularly different. If you had to configure 10,000 bridges a second, perhaps there are steps in the process that would benefit from tiny optimizations. The performance of say the proxy-arp method vs. the linux bridge method might well be different, but this has nothing much to do with the method used to configure them. Also worth mentioning: When I said "short script" I meant 5-10 lines, and you can parallelize things in a script where possible with `&` SOP :P – goldilocks Jun 27 '21 at 12:35
  • 1
    But you are right about the general point: **The systemd method should be the *simplest* method and no less effective than anything else, meaning it should generally be preferred.** I was just curious after reading your other stuff whether you were aware of the linux bridge and what you though of it. – goldilocks Jun 27 '21 at 12:37