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 (22.214.171.124). - 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 (126.96.36.199). - 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 188.8.131.52, which returned :
connect: Network is unreachable
However, pinging anything like google.com or facebook.com is successful, while pinging something like 184.108.40.206 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 220.127.116.11 18.104.22.168 to be the last line of /etc/network/interfaces and
nameserver 22.214.171.124 126.96.36.199 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
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
Please note that I am a beginner with this tech.