-1

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.

Soheil Paper
  • 189
  • 1
  • 9
  • 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. –  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. – Soheil Paper May 21 '19 at 04: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.se] (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. –  May 21 '19 at 05:30
  • This is exactly the same situation as commented in https://raspberrypi.stackexchange.com/questions/11684/how-can-i-connect-my-pi-directly-to-my-pc-and-share-the-internet-connection#comment15836_11684 , replace Windows by Linux and it's exactly the same situation. –  May 21 '19 at 05:52

2 Answers2

0

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

enter image description here

sudo ifconfig enp0s20f0u2 192.168.7.1
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 192.168.7.1 is the IP Address of the USB by this setting:

enter image description here

MatsK
  • 2,791
  • 3
  • 16
  • 20
Soheil Paper
  • 189
  • 1
  • 9
0

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
        address 192.168.7.2
        netmask 255.255.255.0
        network 192.168.7.0
        broadcast 192.168.7.255
        gateway 192.168.7.1

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 192.168.7.1 (note that this is not the same

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

(same as Pi) For the router/gateway use 192.168.7.1 (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@192.168.7.2 to connect to that, second part is could be done easier and you must configure your mode, to share internet with this IP (192.168.7.2) and i will write tomorrow.

Soheil Paper
  • 189
  • 1
  • 9