0

I seem to be having a strange problem with my Raspberry Pi - I can ssh to the Pi, but the Pi cannot ping the computer I am ssh'ing from (Windows firewall allows ICMP packets). I have the Pi configured to have a static IP on eth0, and it is connected directly to my PC with an ethernet cable. The PC has a static ip of 192.168.0.2, a netmask of 255.255.255.0, and a gateway of 192.168.0.5.

The contents of /etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#       post-up route add default gw 10.110.0.11; echo "1" > /proc/sys/net/ipv4/ip_forward ; iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

And at the bottom of /etc/dhcpcd.conf:

interface eth0
static ip_address=192.168.0.5/24
static routers=192.168.0.2
static domain_name_servers=8.8.8.8 8.8.4.4

Output of ifconfig:

eth0      Link encap:Ethernet  HWaddr b8:27:eb:8b:a0:66
          inet addr:192.168.0.5  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:534 errors:0 dropped:0 overruns:0 frame:0
          TX packets:392 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:37966 (37.0 KiB)  TX bytes:44764 (43.7 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:40 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3232 (3.1 KiB)  TX bytes:3232 (3.1 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:0b:81:89:08:c9
          inet addr:10.110.191.221  Bcast:10.110.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20 errors:0 dropped:10 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8486 (8.2 KiB)  TX bytes:5814 (5.6 KiB)

The end goal is to use iptables with MASQUERADE to allow the Windows PC to access the internet using the Pi's connection on wlan0, which also hasn't been working - I figured this should be resolved first and is indicative of a deeper problem, but I am new to networking so any advice is deeply appreciated!

  • If your RPi is not able to connect to the Internet over WLAN0, I'd suggest getting that working first before chasing after other issues. Your RPi router isn't going to do you much good otherwise. Based on the information provided, the RPi and Windows PC are communicating -- ssh works -- so the Windows firewall is a likely culprit. I assume the PC can ping the RPi. Try another device, or (not recommended) modify the firewall settings. – bobstro Jan 12 '18 at 11:31
  • 1
    It is difficult to see what your question is. You haven't specified OS; are using incomplete/obsolete settings (which do not seem logically consistent) and seem to have 2 different networks. How to set up networking/WiFi shows how to setup normal networking. – Milliways Jan 12 '18 at 11:51
  • @bobstro the RPi is able to connect to the internet over wlan0 only after I manually add the default gateway. The PC can ping the RPi. – Billy Kalfus Jan 12 '18 at 16:09
  • @Milliways I'm using Windows 10 on the PC and Raspbian Wheezy on the Pi. Can you elaborate on the inconsistencies? I have seen the link you included and followed the instructions from there. – Billy Kalfus Jan 12 '18 at 16:11
  • @BillyKalfus - Safe to assume the RPi is getting its address for WLAN0 via DHCP from your router? If the PC can ping and ssh to the RPi, it's a pretty safe bet that it's the PC Windows firewall configuration preventing pings from the RPi to the PC. That doesn't sound like your main problem. Work on getting the WLAN0 link to come up 1st, then you can do more testing from the PC. Figure out why it's not getting the default gateway via DHCP. Keep in mind, your RPi can only have ONE default gateway. You are specifying one in /etc/dhdpcd.conf (192.168.0.2) that might be over-writing DHCP's. – bobstro Jan 12 '18 at 17:39
1

Your RPi can only have ONE default gateway. You are specifying one in /etc/dhdpcd.conf (192.168.0.2) that might be over-writing the default router assigned by DHCP. Try removing that line.

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.