Tuesday 9 May 2023

How to share internet between ubuntu pc using a usb wifi dongle?

pcA: ubuntu with usb dongle, with internet

pcB: ubuntu without usb dongle, no internet


step1: check the IP address of pcA if change the IPv4 Method to "Shared to other computers". Prior to this, pcA should have a default IP address and we named it as pcAip1.

Please take note that do not change any setting on "USB Ethernet" because it is an internet connection.

You should change the setting only on "PCI Ethernet".

Open setting of "PCI Ethernet", select IPv4, select "Shared to other computers" under IPv4 Method.

Once it is done, just click Apply.

Then, open terminal and type "nmcli dev show eth0" where eth0 is the network interface name of "PCI Ethernet", sometime it is named as "enp8s0", "enp3s0", etc.

You should get IP address of pcA under "Shared to other computers" condition and we named it as pcAip2:-

IP4.ADDRESS[1]:                         10.42.0.1/24

You will see a different IP address if you change the "Shared to other computers" to Automatic or Manual, which is pcAip1. Write down the pcAip2.

Change it back to manual IP addresss so that you can connect to pcB using original IP.


step2: ssh and login to pcB using default IP address or pcBip1, type "sudo nmtui", edit connection of wired connection

change the setting from before to after as following:-

before, we have pcBip1: 10.201.56.19


after, we have pcBip2: 10.42.0.2


where you should define a temporary IP address of pcB which is 10.42.0.2/24, Gateway you should put pcAip2 which is 10.42.0.1 without 24, DNS servers also the same.

Once it is done, you can reboot pcB.

step3: now from pcA, change again the IPv4 method from manual to "Shared to other computers".

Open terminal, you can try to ssh login pcB using pcBip2 address. Once you login, you can try to ping www.google.com. If you able to receive a reply from Google, then congrats. If not, something wrong with your setting, try again.


step4: now in pcB, you have done your business with internet connection, you want to switch it back to original setting which is from pcBip2 to pcBip1. You can just reverse the setting in step2. Then, you can reboot pcB.


step5: back to pcA, you can restore the PCI Ethernet setting back to pcAip1. You should able to connect pcBip1 as usual, but pcB should not have any internet now

No comments:

Post a Comment