I have Manjaro kde on a laptop that has an Ethernet adapter but no wifi adapter. I have a nearby Raspberry pi that has an internet connection via a power line adapter to the router.
Can I share the internet connection from the Pi to the Manjaro laptop by connecting a USB to Ethernet adapter to the Pi and thus connecting the two via network cable?
I have tried this and according to sudo dmesg the adapter seems to be recognized in the Pi but the resulting network connection in Manjaro keeps getting disconnected.
Do I need to do some sort of iptables/routing magic in Manjaro and/or the Pi to make this work? I suppose I need the Pi to work as a switch or a hub but also continue to work as a normal computer as well.
Goal:
Share the internet/network connection from a Raspberry Pi running Ubuntu Server 22.04 via a USB-To-Ethernet adapter to a nearby laptop running Manjaro.
What I did:
First of all I turned off “Predictable network interface names” in my Ubuntu Server 22.04. I didn’t really need to but I just wanted to! Because I was running it on a Pi 4 I had to do this by adding net.ifnames=0 to the beginning of the line in /boot/firmware/cmdline.txt
My Ubuntu Pi is connected to the router (via a powerline adapter) using the Pis ethernet adapter. I now connected the USB-To-Ethernet adapter to a spare USB 3 port on the Pi and used a regular ethernet cable to connect it to my laptops ethernet adapter. It did not need to use a crossover cable.
In my case the Pis onboard ethernet was now eth0 and the adapter was eth1.
I then followed the instructions from this archlinux wiki.
Assign a static IPv4 address to eth1:
ubuntu@ubuntu:~$ sudo ip link set up dev eth1
ubuntu@ubuntu:~$ sudo ip addr add 192.168.123.100/24 dev eth1
Give the ethernet interface of the laptop (client) a static IP address and a default route via eth1
• I was able to do these steps using “System Settings” in Manjaro.
• I gave my laptops ethernet interface an ip (192.168.123.15) in the same subnet as the ethernet interface of eth1 on Ubuntu Pi (192.168.123.100).
• Then I told the laptops ethernet interface to use the Ubuntu Pi eth1 interfaces ip address (192.168.123.100) as its default gateway.
• I also assigned DNS servers (8.8.8.8 , 8.8.4.4 for Google DNS)
• Now the USB-To-Ethernet adapter should light up and you should be able to turn off Wifi on the laptop and continue with network/internet access!
• Note: This will all be lost if you reboot the Pi but you could run a script to configure the iptables rules on boot up.