i am having issues with my raspberry pi zero W.
so my setup is like this:
I have a laptop which is connected to the internet over wifi (fedora 27 workstation) on interface wlp4s0
.
now i want to bring the pi online by forwarding the traffic from my pi over the usb/ethernet through my computer to the router
I have connected my Rpi zero W over usb to my computer and installed P4wnP1 from here https://github.com/mame82/P4wnP1 by flashing stretch lite first and then cloning the repo and running the install.sh
script.
Now the ip configured from that script is 172.16.0.1
and i can ssh to it by first setting the ip address of my usb /ethernet (whatever, im not sure what it is) interface to 172.16.0.2
apparently the names of my interfaces are kinda weird, but it is called enp0s20f0u6i3
btw can anyone tell me why my interface names are so weird?
so after changing the ip address of my interface i ssh into my pi and set my gateway with sudo route add -net default gw 172.16.0.2
now when i try to ping for example 8.8.8.8
from my pi i get
pi@MAME82-P4WNP1:~ $ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 172.16.0.2 icmp_seq=1 Destination Port Unreachable
From 172.16.0.2 icmp_seq=2 Destination Port Unreachable
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1001ms
my ifconfig on my computer looks like this
$ ifconfig
enp0s20f0u6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::63c0:ffbc:48f3:107d prefixlen 64 scopeid 0x20<link>
ether fe:ac:74:85:37:dd txqueuelen 1000 (Ethernet)
RX packets 6 bytes 424 (424.0 B)
RX errors 1 dropped 0 overruns 0 frame 0
TX packets 20 bytes 4155 (4.0 KiB)
TX errors 290 dropped 0 overruns 0 carrier 0 collisions 0
enp0s20f0u6i3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.0.2 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::c950:4a09:60ad:ff88 prefixlen 64 scopeid 0x20<link>
ether 42:63:65:12:34:56 txqueuelen 1000 (Ethernet)
RX packets 1013 bytes 72317 (70.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 679 bytes 75610 (73.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether c8:5b:76:6b:e4:90 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xf1200000-f1220000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 391 bytes 37964 (37.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 391 bytes 37964 (37.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:08:e4:d3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.106 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::ebcf:d3b1:5a74:185e prefixlen 64 scopeid 0x20<link>
ether e4:a7:a0:99:2e:8d txqueuelen 1000 (Ethernet)
RX packets 7185 bytes 3038480 (2.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7161 bytes 1399795 (1.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
and on my pi
pi@MAME82-P4WNP1:~ $ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.0.1 netmask 255.255.255.252 broadcast 172.16.0.3
inet6 fe80::4063:65ff:fe65:4321 prefixlen 64 scopeid 0x20<link>
ether 42:63:65:65:43:21 txqueuelen 1000 (Ethernet)
RX packets 753 bytes 72772 (71.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1126 bytes 95763 (93.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.24.0.1 netmask 255.255.255.0 broadcast 172.24.0.255
inet6 fe80::ba27:ebff:fe5e:ceb7 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:5e:ce:b7 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1216 (1.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
route -n
on my computer:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.2.1 0.0.0.0 UG 600 0 0 wlp4s0
172.16.0.0 0.0.0.0 255.255.0.0 U 0 0 0 enp0s20f0u6i3
192.168.2.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp4s0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
and on my pi:
pi@MAME82-P4WNP1:~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.0.2 0.0.0.0 UG 0 0 0 usb1
172.16.0.0 0.0.0.0 255.255.255.252 U 0 0 0 usb1
172.24.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
resolv.conf
on my pi
pi@MAME82-P4WNP1:~ $ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 10.46.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
and /etc/network/interfaces
on my pi:
pi@MAME82-P4WNP1:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
dns-nameservers 8.8.8.8 8.8.4.4
auto usb0
iface usb0 inet manual
auto usb1
iface usb1 inet manual
I have been searching for a solution for almost 2 days now (like all day), but nothing worked.
although i could install git and clone the repo before i ran the install.sh
file. But back then my pi did not have a static ip address, it would always be 169.254.xxx.xxx
(pretty random). I retrieved the ip address from the pi with sudo tshark -i (interface)
and then changed the ip of my interface to ssh into the pi.
i have tried so many things, like rebooted 20 times after making changes to resolv.conf
or /etc/network/interfaces
on the pi, but nothing worked.
can anyone help me with this?
And i think the problem is not the gateway on the pi. I think it is something on fedora that prevents the traffic from being rerouted.
I really don't know what to do. I just want the pi to get online.
any help would be very much appreciated.
UPDATE: all i needed to do was reset my iptables, i.e. iptables -F
and set the outbound rule again iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE
. But I need to do this everytime I restart my computer and I cannot find a workaround to that. Maybe someone has an idea.