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!

Milliways
  • 62,573
  • 32
  • 113
  • 225
Billy Kalfus
  • 103
  • 3

1 Answers1

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.

bobstro
  • 3,978
  • 15
  • 27