2

I have my Pi2 recently configured and run into some networking problems. When I tried setting Pi2's IP address to a static IP (192.168.1.200 in this case), upon newly starting up, it can already reach the outside network (e.g. can ping 8.8.8.8). However, Pi2 remains unreachable from other machines from within my home network, i.e. when my Pi2 address is 192.168.1.200:

$ ping 192.168.1.200

Pinging 192.168.1.200 with 32 bytes of data:
Reply from 192.168.1.111: Destination host unreachable.
Reply from 192.168.1.111: Destination host unreachable.
Reply from 192.168.1.111: Destination host unreachable.
Reply from 192.168.1.111: Destination host unreachable.

Ping statistics for 192.168.1.200:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

The weird phenomenon that I don't totally understand is, if I initiate by doing a ping from my Pi2 to my other home computer, i.e. from Pi2 do a ping 192.168.1.111, the other home computer is reachable by ping from Pi2. And then, my other home computer can reach Pi2 afterwards, with ping and ssh, etc. This is very inconvenient because I want to remotely access my Pi2 for my use, and I don't want to write a script to find out and then initiate ping to every existing IP addresses within the home address.

My home ISP router is at 192.168.1.1, here is my /etc/network/interfaces:

source-directory /etc/network/interfaces.d
## no files in the above directory

auto lo
iface lo inet loopback

allow-hotplug eth0
## eth0 not plugged in
iface eth0 inet dhcp

allow-hotplug wlan0
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8 8.8.4.4
wpa-ssid "MY SSID"
wpa-psk "my psk"

Here is my /etc/dhcpcd.conf:

# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
####################
# EDITA IP STATICA #
####################
interface wlan0
static ip_address=192.168.1.200/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

Output from sudo route -n:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 wlan0
0.0.0.0         192.168.1.1     0.0.0.0         UG    303    0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0

Pi2's /etc/resolv.conf:

# Generated by resolvconf
nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

Please let me know your suggestions to find out the source of problem. Thanks in advance.

techraf
  • 4,353
  • 10
  • 32
  • 43
menuhin
  • 171
  • 1
  • 4

2 Answers2

1

Check out the ARP tables on all devices. If a device receives an address from DHCP it can change when the lease expires. However, all devices on the network are not notified about the new address, so they may have an IP address associated with the old user of the address, sometimes for hours. When you ping from the Pi that causes the other device to learn the new MAC address for an IP address.

To fix, use static addresses for everything. Or, use persistent DHCP addresses (a/k/a reservations) (what I do): everything still uses DHCP but they always get the same address. The exact way to do this differs based on router manufacturer.

dk1
  • 111
  • 2
1

So I thought I found the root cause of this problem:

The WiFi USB dongle was not fully supported: it has a Realtek RTL8191S WLAN chipset and although it was fully recognized and even the static IP somewhat worked (after initiating a ping as described above), DHCP was not fully supported anyways. Some other people ran into similar problems with the same dongle: http://www.forum-raspberrypi.de/Thread-csl-wlan-usb-stick-funktioniert-nicht

I did an rpi-update to update the firmware and then after reboot, the same static IP setting was all working fine. And I can ping / ssh from the 192.168.1.111 and other machines within the local network without having to do any ping from the Pi2 first.

However, after I did some other software package installation and updates (apache2, php5, MySQL, texlive, gimp, emacs, and some user USB drive mount-unmount scripts), the problem reappeared again. :\

menuhin
  • 171
  • 1
  • 4