1

Considering the following situation: There is a available WIFI source which is connect to Internet, and there is a desktop computer which is lack of WIFI adapter. Then a Raspberry Pi 4 is provided with sufficient Ethernet cable.

Is it possible to direct connect Raspberry Pi 4 with computer and use the wireless adapter to receive and send data with the Environment WIFI source?

I don't know if Raspberry Pi are able to access WIFI adapter and Ethernet adapter simultaneously. The tutorial and article in the internet usually using 3rd part USB component.

  • 1
    There are several solutions depending what you needs. Does the desktop computer only needs access to the internet or must it also connect to other devices on your local network? The latter would make setup more complex. – Ingo May 13 at 22:14
  • @Ingo, Only internet. But additional hardware component is not a good option. Is it possible to use the resource on Raspberry Pi 4 only to solve the problem? – Audra Jacot May 14 at 0:05
  • @Ingo, but any software component (driver, kernel module, daemon) is all acceptable – Audra Jacot May 14 at 0:09
2

What you need is a simple router that routes traffic from the desktop computer to your WiFi internet router. This can simply be configured using systemd-networkd.

Just follow to Use systemd-networkd for general networking. You can use section "♦ Quick Step". Then come back here.

Now configure wpa_supplcant to connect to your internet router. Create this file with your settings for country, ssid and psk:

pi@raspberrypi:~ $ sudo -Es   # if not already done
rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE

network={
    ssid="RPiNet"
    psk="verySecretPassword"
}
EOF

rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
rpi ~# systemctl disable wpa_supplicant.service
rpi ~# systemctl enable wpa_supplicant@wlan0.service
rpi ~# rfkill unblock 0

Configure interfaces with these files. Be sure that you do not use the same subnet than from your internet router. In this example I use subnet 192.168.4.0/24 for the desktop computer. The subnet of your internet router must be different from this.

rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Address=192.168.4.1/24
IPMasquerade=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF

rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
DHCP=yes
EOF

Reboot, and it should do.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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