Cannot resolve hostname

6,085

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.

Share:
6,085

Related videos on Youtube

Carlos Perez
Author by

Carlos Perez

Updated on September 18, 2022

Comments

  • Carlos Perez
    Carlos Perez over 1 year

    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

    • Admin
      Admin almost 10 years
      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.
    • Carlos Perez
      Carlos Perez almost 10 years
      @nwildner I update my question
    • Admin
      Admin almost 10 years
      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 :)
    • Carlos Perez
      Carlos Perez almost 10 years
      @nwildner nothing happend with the dhclient eth0 command :/
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 10 years
      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?
    • Admin
      Admin almost 10 years
      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?
    • Carlos Perez
      Carlos Perez almost 10 years
      @Gilles yes it is connected using a cable, and I assign the ip address on /et/network/interface/ and still having the same problem
    • derobert
      derobert almost 10 years
      @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.
    • Carlos Perez
      Carlos Perez almost 10 years
      @derobert I try with the ifdown eth0 and ifup eth0 and im still having the same problem
    • derobert
      derobert almost 10 years
      @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).
    • Carlos Perez
      Carlos Perez almost 10 years
      @derobert yes now the ip show after running the command ip addr ls I update my question
    • derobert
      derobert almost 10 years
      @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).
    • Carlos Perez
      Carlos Perez almost 10 years
      @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 :/
    • derobert
      derobert almost 10 years
      @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.
  • Carlos Perez
    Carlos Perez almost 10 years
    wooow you are a genius man, thank you so much :))
  • Ludwig Schulze
    Ludwig Schulze almost 10 years
    wlan with hotplug?
  • derobert
    derobert almost 10 years
    @Braiam allow-hotplug should bring it up when udev gets the device. I don't think OP is running Network Manager. Also not sure if OP is even using the wlan.