I connected my Pi Zero to my PC ( Linux LMDE 3 Cindy) via USB port successfully, SO i want to connect to internet via my laptop which is connected to internet by its WIFI.

I found this instruction or this question via raspberrypi.stackexchange but those are working for window or MAC OS,but i don't find it for Linux!!!!

SO i need the similar instruction for enabling sharing my internet via USB enp0s20f0u1 device (PI Zero) in Linux. for example in windows we need to :

In the WiFi Properties window, click on the “Sharing” tab : similar to this photo:

WiFi internet sharing

So in Linux version what is the similar instruction to doing this?

Thanks a lot.

  • 1
    Your question seems to be about sharing an Internet connection in as desktop Linux. To what it is shared, the Pi, is irrelevant in this context.
    – user103604
    May 20 '19 at 22:00
  • I want to share my laptop internet to my raspberry which is connected to my laptop via USB Port. I found the way's for windows OS but not for Linux OS. SO i asked here. May 21 '19 at 4:46
  • 1
    Thank you for clarifying. The Raspberry Pi is NOT the issue then, it's irrelevant, as I previously commented. For general Linux questions there's Unix & Linux (make sure to post all the relevant information about your distro and version). Your question is about sharing an Internet connection in a desktop Linux. To what it's shared DOESN'T MATTER. The Raspberry Pi needs no special configuration for that, there's nothing RPi specific in using a shared internet connection.
    – user103604
    May 21 '19 at 5:30
  • This is exactly the same situation as commented in raspberrypi.stackexchange.com/questions/11684/… , replace Windows by Linux and it's exactly the same situation.
    – user103604
    May 21 '19 at 5:52

here you could find good suggestion here :

as it said on page 16 add this to /etc/network/interfaces ( by sudo nano /etc/network/interfaces):

allow-hotplug wlan1
iface wlan1 inet manual
   wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug usb0
iface usb0 inet static

After that Save the file and run

sudo ifdown usb0 

(this may fail, its fine)

sudo ifup usb0
ifconfig usb0

unplug pi and then connect it to usb again .it'll probably be set up for DHCP by default so change it to Configure IP4 Manually:

For the IP address pick (note that this is not the same

as the Pi Zero's address!) For the subnet mask, use

(same as Pi) For the router/gateway use (same as Pi)

If you didn't use our suggested netconfig above on the Pi, you may have to adjust this one to Linux similar to this: enter image description here

and then you could run sudo ssh pi@ to connect to that, second part is could be done easier and you must configure your mode, to share internet with this IP ( and i will write tomorrow.


Based of this PowerPoint slide, then next step is doing this commands in Linux like this:

enter image description here

sudo ifconfig enp0s20f0u2
sudo sysctl net.ipv4.ip_forward=1
sudo iptables --table nat --append POSTROUTING --out-interface wlp2s0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface enp0s20f0u2 -j ACCEP

The enp0s20f0u2 is the USB port of Raspberry Pi Zero, and is the IP Address of the USB by this setting:

enter image description here

  • The first picture serves no apparent purpose, because you included the relevant commands in the answer already. I would remove it. Mar 27 '20 at 9:02

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.