1

I'm using a Debian on a RaspberryPi and the problem that I'm having is that I can't connect to the Internet.

Every time I try I see a message that says "cannot resolve hostname". From the terminal, I tried:

$ ping www.google.com 
unknown host google.com

$ ping 8.8.8.8
network is unreachable

output of 'ip addr list'

1: <LOOPBACK, UP, LOWER_UP> mt 65536 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 vrd 00:00:00:00:00:00:
   inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever

2: eth0: <BOADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 dis pfifo_fast state UP qlen 100
   link/ether b8:27:eb:18:b9:17 brd ff:ff:ff:ff:ff:ff

This appears after doing the ifdown eth0 and ifup eth0 as drobert suggest

  innet 1393.182.112.9116 brd 139.182.255.255 scope global eth0
    valid_lft forevere preferred_lft forever

ip route ls

139.182.0.0/16 dev eth0 proto kernel scope link src 139.182.112.9

etc/network/interface

auto lo

iface lo inet loopback
iface eth0 inet dhcp

address 139.182.112.9

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.cong
iface default inet dhcp

ifconfig

bcast: 139.182.255.255
Mask: 255.255.0.0

I try the up route list command nothing happed

Carlos Perez
  • 113
  • 1
  • 4
  • 2
    please post the contents of the following commands: `ip addr list` and `ip route list`. Your problem seems to be the lack of a default route to your gateway. –  May 19 '14 at 20:51
  • @nwildner I update my question – Carlos Perez May 19 '14 at 21:10
  • 1
    Well, it seems that you don´t even have an ip address. Try `dhclient eth0` to aquire an address from your lan(if there is a dhcp server somewhere). Cheers :) –  May 19 '14 at 21:12
  • @nwildner nothing happend with the dhclient eth0 command :/ – Carlos Perez May 19 '14 at 21:22
  • Your Pi isn't connected to any network. What kind of network connection does it have? Is there a cable plugged into `eth0` and if so what's at the other end? – Gilles 'SO- stop being evil' May 19 '14 at 22:15
  • Hi Carlos. Does `dhclient` even return error or no screen response? It seems that you have connectivity(`LOWER_UP` on ip addr list) but you don´t have a L3 configuration(addressing/routing). Other computers connected to this network aquire ip address automatically? –  May 19 '14 at 22:46
  • @Gilles yes it is connected using a cable, and I assign the ip address on /et/network/interface/ and still having the same problem – Carlos Perez May 21 '14 at 17:02
  • @nwildner no no error :/ – Carlos Perez May 21 '14 at 17:03
  • @CarlosPerez Your `ip addr ls` output doesn't show an IP address. So for some reason the address you assigned in `/etc/network/interfaces` didn't take. I suggest `ifdown eth0` (ignore any errors) and then seeing if you get an error from `ifup eth0`. – derobert May 21 '14 at 17:15
  • @derobert I try with the ifdown eth0 and ifup eth0 and im still having the same problem – Carlos Perez May 21 '14 at 17:21
  • @CarlosPerez did either produce an error message? Also, does `ip addr ls` show the IP address now? Does `ip route ls` show your default gateway? If not, please edit your question to include the `/etc/network/interfaces` (if you want to obscure the IP addresses, feel free to do so). – derobert May 21 '14 at 17:23
  • @derobert yes now the ip show after running the command ip addr ls I update my question – Carlos Perez May 21 '14 at 17:25
  • 1
    @CarlosPerez I'm going to assume the weird 4-digit octets in the IP address are just a mistake in editing the question. It appears you don't have a default gateway; did you specify one (with the `gateway` clause) in your `/etc/network/interfaces`? Also, make sure you have `allow-hotplug eth0` or `auto eth0` in there somewhere (otherwise, it won't be started on boot). – derobert May 21 '14 at 17:29
  • @CarlosPerez (Also, check your netmask. It's possible 255.255.0.0 is right, but I doubt it.) – derobert May 21 '14 at 17:31
  • @derobert thanks for helping me, I update my question again, so you can see the etc/network/interface and the ifconfig. sorry but im reall y new at this :/ – Carlos Perez May 21 '14 at 17:35
  • @CarlosPerez that is a very confused `/etc/network/interfaces`. Let me post an example as an answer, because I think that'll get it working for you. Keep in mind you must do an ifdown/ifup pair each time to make the changes take effect. – derobert May 21 '14 at 17:38

1 Answers1

2

Your /etc/network/interfaces is confused. There are several methods of assigning an IP address to the interface; you've specified dhcp which means to ask the DHCP server for an address. But then you went ahead and specified an address anyway.

I think what you want is something like this

auto lo
iface lo inet loopback

allow-hotplug eth0         # omit this line if using ifplugd
iface eth0 inet static
    address 139.182.112.9
    netmask a.b.c.d
    gateway 139.182.e.f

allow-hotplug wlan0

iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

You hopefully know the right netmask and gateway. If not, you'll need to get them from your network administrator. They should have been provided along with the IP address.

derobert
  • 107,579
  • 20
  • 231
  • 279