Connect 2 PCs, one has internet via USB-tethering

Hi,

I have 2 PCs (Manjaro 23.1.1, rolling release, up to date, with KDE).

Both PCs need internet, but only one (let’s call it “master”) has internet access via USB tethering (connected to a smartphone via USB). So I connected both PCs with a LAN cable, so they would both have internet access.

I am not sure what to do in KDE’s NetworkManager. On both PCs, I am in “Settings → Network → Connections”. On both PCs, I added a connection which requires IPv4. I set the “method” to “manual”, assigned an address to each of the PCs, and for the slave, I gave the IP of the other PC as gateway.

master
slave

After that, each PC can successfully ping or SSH the other one via their IP addresses. However, the slave still complains that while it is connected to a network, it still has no internet.

There is an ubuntu thread that says I should choose method “Shared to other computers”, but for me, this does not change the situation on the slave, and the master seems to refuse making new internet connections (existing ones still work).

Can anyone please assist me on how to get internet for the slave working, too?

Thanks on advance.

Is there an error message? Have you tried “automatic” on one and “shared to other computers” on the other?

Can you ping an IP address? If not, then probably the routing table is not set up. Can you ping an IP address but not a domain name? Then most likely the DNS server is not configured correctly.

I cannot recreate this issue right now, but IIRC ping 8.8.8.8 fails on master after a while.

I tried using “shared to other computers” on master, and also, in addition, “automatic” on slave. In all cases (including the case of the OP), the slave can not ping 8.8.8.8 - no reply.

No, in all scenarios I tried, the slave can not ping any IP adress. ping 8.8.8.8 gives no reply. For the routing table: route -n outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.178.23  0.0.0.0         UG    20100  0        0 enp6s0
192.168.178.0   0.0.0.0         255.255.255.0   U     100    0        0 enp6s0

This looks rather good, so I think the slave is configured fine.

What about the master? Note that the address space must fit to the ip of the internet connection, otherwise the slave won’t be able to connect to internet, only to your the local master. Different IP range, different Network :wink:

In all master configurations, it always looks like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.42.129  0.0.0.0         UG    102    0        0 enp0s20u2u3
192.168.42.0    0.0.0.0         255.255.255.0   U     102    0        0 enp0s20u2u3
192.168.178.0   0.0.0.0         255.255.255.0   U     101    0        0 eno1

Given the masks and that we failed to ping 8.8.8.8, I think that should be correct?

# On Master
nmcli connection modify myconnection ipv4.method shared
sudo systemctl restart NetworkManager
# On Slave
nmcli connection modify myconnection ipv4.method auto
sudo systemctl restart NetworkManager

Re/plugin the Ethernet cable. By default it should get the IP via DHCP automatically on the slave device. Really, just tested. I can ping simply any Domain.

1 Like

192.168.42.* & 192.168.178.* != same network.

Also DNS=192.168.178.23. Do you have a dns server running on the “master”? I think your phone should handle the dns requests (and if you configure it as automatic, this probably will get the correct settings incl dhcp server).

Do you have wifi on both machines? Then setting up the “master” as a mobile hotspot and using that connection on the “slave” might be an easier solution if you cant get the cable to work.

Also you probably need NAT to make this work otherwise the phone will not know to where the packets from/to 192.168.178.X should be forwarded. The best option is to get NetworkManager’s automatic configuration to work because that should take care of everything: DNS, DHCP, routing, NAT, …

I followed your steps, but it still does not work. The master can still reach the internet, but the host gets:

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.178.24 icmp_seq=1 Destination Host Unreachable

Also, with these changes, slave can still ping master, but master cannot ping slave anymore. Anyways, I wonder how they both get their IPs with this proposal, as “shared” and “auto” do not allow specifying IPs in the listbox.

Hm, correct. But how do I change that weird 192.168.42.*? I cannot see an entry in the Network Manager settings.

Wow, I removed it and now everything works on both machines (with megavolt’s solution). Still very slow, but it works. I had the DNS server only in there because that weird link (from askubuntu) had set the DNS server, too. I will probably still accept megavolt’s solution, because it was the main thing that made it running.

Sadly, when I use WIFI instead of USB tethering, the connection (from master) keeps going down every few seconds.

You should, because it is basically what I am saying too, you just do it in cli instead of gui. :slight_smile:
You share the network from the master and client is set to auto.
If it works with cable you should obv use that!

Feel free to click the solution button :white_check_mark: on megavolts post so the thread can be closed with a solution.

I tested for 2 more days, including reboots, suspend 2 RAM etc. It worked, except that, in order to get USB tethering to work on the master, I had to unplug the LAN cable to the other PC, then connect the mobile phone, and only then re-plugin the LAN cable to the other PC.

With that, it now all works. Will accept the answer. Thanks everyone!

1 Like

Think about it.
You connect the 2 computers without any kind of sharing setup THEN add the sharing by connecting the phone. You need to tell the client that things have changed, and one way to do that is to disconnect the cable (so the connection is lost) then reconnect it and this time there IS a share so the client sets up the connection that way instead.
You can do this in cli, but disconnecting > reconnecting the physical cable works the same. :slight_smile:

Glad you got it working.
Happy new year! :partying_face:

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.