-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

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,882
  • 3
  • 17
  • 22
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