I have set up a new installation of NOOBS on a Raspberry Pi 2. I configured a static IP address by adding this to /etc/dhcpcd.conf:
interface eth0 static ip_address=192.168.2.102/24 static routers=192.168.2.0 static domain_name_servers=192.168.2.1
However, there doesn't seem to be any default gateway now, so I can't access the internet:
$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 * 255.255.255.0 U 202 0 0 eth0 $ ping -c 1 google.com connect: Network is unreachable
If I manually add it, everything works:
$ sudo route add default gw 192.168.2.1 eth0 $ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.2.1 0.0.0.0 UG 0 0 0 eth0 192.168.2.0 * 255.255.255.0 U 202 0 0 eth0 $ ping -c 1 google.com PING google.com (220.127.116.11) 56(84) bytes of data. 64 bytes from syd09s01-in-f142.1e100.net (18.104.22.168): icmp_seq=1 ttl=57 time=6.45 ms --- google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 6.457/6.457/6.457/0.000 ms
But this needs to be done every time I reboot. I tried adding:
/etc/network/interfaces as suggested on another forum but it made no difference.
Am I missing something?
Here is the contents of my
source-directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet manual allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf