Hardware: Pi 2
OS: Raspberry Pi OS 32-bit
No firewall. Running over ethernet (no WiFi card)
I am following a tutorial to set up a Pi as a file server for home. For this, I need to install Samba. Whenever I run sudo apt-get install samba samba-common-bin
and confirm disk space usage, I get the following output:
Err:1 http://mirrors.switch.ca/raspbian/raspbian buster/main armhf python-dnspython all 1.16.0-1
Cannot initiate the connection to mirrors.switch.ca:80 (209.115.181.106). - connect (101: Network is unreachable)
E: Failed to fetch http://mirrors.switch.ca/raspbian/raspbian/pool/main/d/dnspython/python-dnspython_1.16.0-1_all.deb Cannot initiate the connection to mirrors.switch.ca:80 (209.115.181.106). - connect (101: Network is unreachable)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Of course the first thing I tried was to ping mirrors.switch.ca at the IP 209.115.181.106, which returned :
connect: Network is unreachable
However, pinging anything like google.com or facebook.com is successful, while pinging something like 8.8.8.8 returns the above message. (Pinging any of the above IPs from my Windows PC works. Both my PC and Pi are connected to the same router via ethernet)
At this point, after doing some digging, I also noticed that my initial sudo apt-get upgrade
after setting up the Pi failed for the same reason.
Following the accepted answer on this question, I added dns-nameservers 8.8.8.8 8.8.4.4
to be the last line of /etc/network/interfaces and nameserver 8.8.8.8 8.8.4.4
as the last line of /etc/resolve.conf.
After these changes, I was able to successfully run sudo apt-get upgrade
, but sudo apt-get install samba samba-common-bin
continues to return the same error message.
This is the output from ifconfig
:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 2607:9880:3310:4a:6387:cd42:1739:7bd7 prefixlen 64 scopeid 0x0<global>
inet6 2607:9880:3310:4a::c58f prefixlen 128 scopeid 0x0<global>
inet6 fe80::155b:afb7:2eca:cfed prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:40:5c:53 txqueuelen 1000 (Ethernet)
RX packets 6744 bytes 1301368 (1.2MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 712 bytes 85209 (83.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 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
I also made some configuration changes when setting up the Pi to allow SSH connections. If this config is relevant, I will post it.
edit - SSH config:
To set up for SSH, I started by creating an empty file:
sudo touch boot/ssh
Then I edited /etc/dhcpcd.conf to uncomment the lines with interface eth0
and static ip_address=...
, and set the IP to 192.168.0.10/24
This is the result from route print
on my Windows machine:
Please note that I am a beginner with this tech.
Thank you.
connect: Network is unreachable
. That means your packets are not being routed to the correct network. You may confirm this by runningtraceroute
from your RPi. – Seamus Aug 04 '20 at 19:17traceroute
, including ones that were otherwise working (google.com). Runningtraceroute
to my PC appears to work just fine. What should I do going forward? – Daniel F Aug 04 '20 at 20:05route -n
on your RPi - what does it show? – Seamus Aug 04 '20 at 23:27route print
command - here's how. – Seamus Aug 05 '20 at 19:15dhcpcd.conf
. I'll explain what you should have done in my answer, but for now, let's make a quick test: Restore yourdhcpcd.conf
to its original state, and reboot your Pi. That should restore your gateway route (which is part of what DHCP does), and give you connectivity. Can you do that? – Seamus Aug 05 '20 at 21:43dhcpcd.conf
solved my connectivity issues. I'll accept your answer once you post it. Thank you for your patience and assistance! – Daniel F Aug 05 '20 at 23:33dhcpcd.conf
" Are you OK with this? – Seamus Aug 06 '20 at 06:03