Score:0

Share desktop's WiFi internet with Raspberry Pi over ethernet

in flag

I'm trying to set up my RPi in headless but having trouble with sharing my Ubuntu desktop's WiFi internet over ethernet. This question has been asked before indeed, but they just don't work for me for some reason.

Note: the RPi does have WiFi and I can use a VNC Viewer to set this up via the desktop. But...I'm trying to learn more about networking, so appreciate any help!

The standard solution is use nm-connection-editor, open Wired Connection goto IPv4 Settings and change Method to Shared to other computers. E.g. this solution but allowing for I'm on 22.04LTS. It doesn't "just work" unfortunately.

I can ssh into the RPi using raspberrypi.local, and here is its interwebs info without WiFi enabled:

pi@raspberrypi:~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d8:3a:dd:02:9d:80 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.159/24 brd 10.42.0.255 scope global dynamic noprefixroute eth0
       valid_lft 3496sec preferred_lft 3046sec
    inet6 fe80::bd30:6f44:d39b:756e/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether d8:3a:dd:02:9d:81 brd ff:ff:ff:ff:ff:ff

The Ubuntu desktop reports:

(base) ➜  ~ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 14:b3:1f:0d:d4:16 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.1/24 brd 10.42.0.255 scope global noprefixroute enp4s0
       valid_lft forever preferred_lft forever
    inet6 fe80::6b87:d248:300a:5cd7/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 7c:67:a2:36:26:49 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.133/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp3s0
       valid_lft 80608sec preferred_lft 80608sec
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:42:de:32:8f brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

The RPi with WiFi enabled reports:

pi@raspberrypi:~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d8:3a:dd:02:9d:80 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.159/24 brd 10.42.0.255 scope global dynamic noprefixroute eth0
       valid_lft 3282sec preferred_lft 2832sec
    inet6 fe80::bd30:6f44:d39b:756e/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d8:3a:dd:02:9d:81 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.198/24 brd 192.168.0.255 scope global dynamic noprefixroute wlan0
       valid_lft 86398sec preferred_lft 75598sec
    inet6 2001:8003:d546:9800:3823:405f:2c2d:1475/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 44695sec preferred_lft 44695sec
    inet6 fe80::6dea:75b5:1713:2454/64 scope link 
       valid_lft forever preferred_lft forever

I can see that when the WiFi is on, we have:

192.168.0.198/24 brd 192.168.0.255 scope global dynamic noprefixroute wlan0

but with only ethernet we have:

inet 10.42.0.159/24 brd 10.42.0.255 scope global dynamic noprefixroute eth0

So both have the same scope and other settings, but one is on my home LAN 192.168.0.198 and the other is on a local IP address to the desktop: 10.42.0.159.

I can see that there are guides which advise setting up a static IP: here, here, and here. But this is only an addressing convenience (right?).

So I'm interested to learn how or what is happening with my desktop that means its internet connection is not being shared on, even though it is set in the Wired Connection IPv4 setting. Are there any other diagnostic info I could look at?

Thank you for any help!

--- Edit

Another networking command run on the desktop:

(base) ➜  ~ nmcli dev show enp4s0
GENERAL.DEVICE:                         enp4s0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         14:B3:1F:0D:D4:16
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Wired connection 1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/12
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.42.0.1/24
IP4.GATEWAY:                            --
IP4.ROUTE[1]:                           dst = 10.42.0.0/24, nh = 0.0.0.0, mt = 100
IP6.ADDRESS[1]:                         fe80::6b87:d248:300a:5cd7/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 1024
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.