4

I'm trying to host an apache2 server on my RasPi, but I can't seem to even complete the first step of updating all the software. Here's the error message:

Err http://archive.raspberrypi.org jessie InRelease

Err http://mirrordirector.raspbian.org jessie InRelease

Err http://mirrordirector.raspbian.org jessie Release.gpg
  Could not resolve 'mirrordirector.raspbian.org'
Err http://archive.raspberrypi.org jessie Release.gpg
  Could not resolve 'archive.raspberrypi.org'
Reading package lists... Done
    W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/InRelease

W: Failed to fetch http://archive.raspberrypi.org/debian/dists/jessie/InRelease 

W: Failed to fetch http://archive.raspberrypi.org/debian/dists/jessie/Release.gpg  Could not resolve 'archive.raspberrypi.org'

W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/Release.gpg  Could not resolve 'mirrordirector.raspbian.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.

I installed Raspbian from NOOBS just yesterday, so I think I'm already up to date, but I am still very lost.

EDIT: /etc/resolv.conf and ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:06:21:c7
      inet addr:192.168.1.119  Bcast:192.168.1.255  Mask:255.255.255.0
      inet6 addr: fe80::142:63fc:b304:5620/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:3701 errors:0 dropped:4 overruns:0 frame:0
      TX packets:1266 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:330709 (322.9 KiB)  TX bytes:222832 (217.6 KiB)

lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:576 errors:0 dropped:0 overruns:0 frame:0
      TX packets:576 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:46904 (45.8 KiB)  TX bytes:46904 (45.8 KiB)

/etc/resolv.conf doesn't seem to be holding anything. I just get this:

#Generated by resolvconf
Modjular
  • 41
  • 1
  • 4
  • 1
    Are you connected to the internet? Can you view the google homepage in a browser? What is the output of ifconfig? – Steve Robillard Dec 21 '15 at 19:27
  • Its connected directly to the ethernet port, and right now I am accessing it through SSH on PuTTY. I believe the connection is fine. – Modjular Dec 21 '15 at 19:31
  • Wait a sec. I can't resolve google.com. – Modjular Dec 21 '15 at 19:32
  • @SteveRobillard I'm really new to the Pi. Was I supposed to configure internet connection separately? – Modjular Dec 21 '15 at 19:35
  • Is the ethernet port of the Pi connected to a router or to your PC – Steve Robillard Dec 21 '15 at 19:35
  • @SteveRobillard Its connected to my router. – Modjular Dec 21 '15 at 19:40
  • Normally, it would pick up the network connection details via DHCP but it looks like it may be having a problem. Can you edit your question and include the output of ifconfig, the contents of /etc/resolv.conf and /etc/network/interfaces – Steve Robillard Dec 21 '15 at 19:43
  • 1
    Have a look at the answer here regarding DNS: http://raspberrypi.stackexchange.com/q/32849/5538 If this is the problem please let us know. – goldilocks Dec 21 '15 at 19:47
  • @goldilocks I think this might be the problem, but does connection to the internet require a DNS? – Modjular Dec 21 '15 at 19:51
  • without DNS you can't hit a site that you don't know the IP address of. – Steve Robillard Dec 21 '15 at 19:53
  • I tried adding google's nameservers to the resolv.conf. Now I'm getting: – Modjular Dec 21 '15 at 19:54
  • ping: icmp open socket: Operation not permitted – Modjular Dec 21 '15 at 19:54
  • Th net doesn't require them but as Steve says [resolving hostnames](https://en.m.wikipedia.org/wiki/Dns) does -- it can be pretty useless without that. If you use DHCP, your router may provide default nameservers, otherwise you'd have to add them. – goldilocks Dec 21 '15 at 19:56
  • You have a firewall configured if ICMP fails. – goldilocks Dec 21 '15 at 19:57
  • @goldilocks Is there a step I should have done before attempting to connect to the internet? I feel as if I missed a crucial piece of information. Every single tutorial I chanced upon seemed to start with "sudo apt-get update". – Modjular Dec 21 '15 at 19:59
  • Whoops, sorry that was probably just a permissions thing. Try `sudo ping ....`. – goldilocks Dec 21 '15 at 20:04
  • @goldilocks Dangit. That worked. And now we're back where we started – Modjular Dec 21 '15 at 20:10
  • Be carefully about adding things to /etc/resolv,conf - depening on your system you may get something like:`# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 nameserver 8.8.4.4` if things like network-manager (I think) is around... – SlySven Dec 21 '15 at 20:17
  • So you can `ping google.com` but you still get the same "Could not resolve" errors from `apt`? – goldilocks Dec 21 '15 at 20:17
  • BTW: mirrordirector.raspbian.org does seem to be operating (it did have a bit of down-time late last month) I'm getting an IP of 5.153.225.207 for it at the moment... – SlySven Dec 21 '15 at 20:22
  • @goldilocks Eureka! I think. The main problem may have been the entire lack of nameservers in the resolv.conf. However, as SlySven mentioned, how should I safely go about configuring the resolv.conf? – Modjular Dec 21 '15 at 20:22
  • I think you'll could add some dns-server lines in /etc/network/interfaces under `ìface eth0 inet dhcp`? Try `man resolvconf`. – SlySven Dec 21 '15 at 20:24
  • @SlySven It may be the newer version of Raspbian, but my etc/network/interfaces holds no 'iface etho0 inet dhcp' , only 'iface eth0 inet manual', and then has an '/etc/dhcpcd.conf' file. – Modjular Dec 21 '15 at 20:33
  • What are the contents of the /etc/dhcpd.conf file. You may want to try changing the iface eth0 inet manual to iface eth0 inet dhcp in your /etc/network/interfaces file. – Steve Robillard Dec 21 '15 at 20:38
  • FTR I've just got a sample one `/etc/dhcpd.conf` and the interfaces file on mine is like yours Modjular - so that may not be your problem... – SlySven Dec 21 '15 at 20:41
  • @SteveRobillard My ultimate goal is to portforward and put my site online, which apparently requires a static IP, so i put some static addresses in the dhcpcd.conf file – Modjular Dec 21 '15 at 20:50
  • 1
    Your modem/router may be able to furnish your Pi with a fixed IP if it is told to reserve one for the MAC that the Pi presents for wired ethernet port or that of a wireless dongle... and you'll have to tell it to port forward to that address anyhow. – SlySven Dec 21 '15 at 21:01
  • Can you/are you in the GUI? Is there a network icon on the toolbar (I have two PC shapes one behind the other but it might not be the same for all cases)? – SlySven Dec 21 '15 at 21:22
  • @SlySven I'm doing it all remotely through command line, so no GUI. – Modjular Dec 21 '15 at 21:47
  • On a Linux box? Fire up a `Xephyr :1 -ac -screen 1024x768 &` on that and then - with a `ssh` sesion started with `-Y` option onto the Pi `export DISPLAY=`PC's name or IP address`:1` `startlxde-pi` ... Xephyr is the Xserver inside an Xserver server :1 is the display to use for that which is started WITHOUT Xaccess control (the -ac) and which the Pi is told to use for any GUI things - such as the start LX desktop script! – SlySven Dec 21 '15 at 21:53
  • @SlySven No luck, I'm on windows – Modjular Dec 21 '15 at 22:05
  • @SlySven Ok, I have access to the GUI again. What am I looking for? – Modjular Dec 21 '15 at 22:15
  • Is there an obvious "network" icon on the taskbar/system tray? – SlySven Dec 21 '15 at 22:23
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/33295/discussion-between-modjular-and-slysven). – Modjular Dec 21 '15 at 22:25

1 Answers1

1

I've had this problem earlier today on my Raspberry Pi. It seems you aren't connected to the internet.

I've recently answered a very similar question; Cannot connect Pi 3 to internet, but I'll put my answer in here too.

Try connecting a display to it, as well as any USB keyboard. Once you have done that, startup your Pi by connecting any Micro-USB cable to your Pi. If you cannot connect a display to your Pi, connect it to your router via Ethernet and connect it to your keyboard and power supply.

Type

sudo apt-get install ssh

Download and install Putty, and I recommend using Fing on the App store to locate your Pi's IP address. When that's done, insert the IP address of your PI into Putty, and continue on to the next steps.

Login (if prompted):

Username: pi

Password: raspberry

Type:

sudo nano /etc/network/interfaces

Make sure your screen looks like this, if not type it in.

img1

When you're done doing that, press Control+X, type y, and press enter.

Now, for the final part, type:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

This time, add the following to the file:

network={
    ssid="Network Name"
    psk="Network Password"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    auth_alg=OPEN
}

Tip: the name and password is case sensitive, so type it exactly as it appears.

When you're done, press Control+X, type y, and press enter again. Now you're ready, type sudo reboot now and now you can try to update your Pi. I also recommend after you update it, to type sudo apt-get install upgrade -y.

Cody Bennett
  • 161
  • 6