keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Raspberry pi doesn't connect to internet

Mon Jul 23, 2018 3:26 pm

Hi,
after changing interternet provider, my raspberry pi doesn't connect to internet. It is present on my lan and I can connect to it by my pc via ssh, but the pi doesn't update and doesn't ping external site.

Code: Select all

sudo apt update
Err:1 http://raspbian.raspberrypi.org/raspbian stable InRelease
  Risoluzione di "raspbian.raspberrypi.org" temporaneamente non riuscita
Err:2 http://archive.raspberrypi.org/debian stretch InRelease
  Risoluzione di "archive.raspberrypi.org" temporaneamente non riuscita
Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze       
Lettura informazioni sullo stato... Fatto
Tutti i pacchetti sono aggiornati.
W: Impossibile recuperare http://raspbian.raspberrypi.org/raspbian/dists/stable/InRelease  Risoluzione di "raspbian.raspberrypi.org" temporaneamente non riuscita
W: Impossibile recuperare http://archive.raspberrypi.org/debian/dists/stretch/InRelease  Risoluzione di "archive.raspberrypi.org" temporaneamente non riuscita
W: Impossibile scaricare alcuni file di indice: saranno ignorati o verranno usati quelli vecchi
I setted an static ip in the file /etc/network/interfaces

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual
auto eth0
iface eth0 inet static
address 192.168.1.138
gateway 192.168.1.254
netmask 255.255.255.0

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

This is my /etc/dhcp/dhclient.conf

Code: Select all

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#	man page for more information about the syntax of this file
#	and a more comprehensive list of the parameters understood by
#	dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#	not leave anything out (like the domain name, for example), then
#	few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
	domain-name, domain-name-servers, domain-search, host-name,
	dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
	netbios-name-servers, netbios-scope, interface-mtu,
	rfc3442-classless-static-routes, ntp-servers;

#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 208.67.222.222, 208.67.220.220, 8.8.8.8, 8.8.4.4;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}
Last edited by keiichi on Mon Jul 23, 2018 4:36 pm, edited 1 time in total.

epoch1970
Posts: 1940
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Raspberry pi doesn't not connect to internet

Mon Jul 23, 2018 4:16 pm

Stretch is different from former releases. Do not use old how-tos.

Remove your configuration from /etc/network/interfaces
Create the appropriate configuration in /etc/dhcpcd.conf

There is no reason to use dhclient, dhcpcd by default fetches IP config via DHCP.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't not connect to internet

Mon Jul 23, 2018 4:40 pm

epoch1970 wrote:
Mon Jul 23, 2018 4:16 pm
Stretch is different from former releases. Do not use old how-tos.
Ok, but first of the change, I have not problem and the configuration was the same.
epoch1970 wrote:
Mon Jul 23, 2018 4:16 pm
Remove your configuration from /etc/network/interfaces
Create the appropriate configuration in /etc/dhcpcd.conf

There is no reason to use dhclient, dhcpcd by default fetches IP config via DHCP.
Ok, I will try it

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Tue Aug 14, 2018 2:05 pm

Now this is my /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback
iface eth0 inet manual
This is my /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.1.138
static routers=192.168.1.254
static domain_name_servers=8.8.8.8
The pi doesn't connect to internet

Code: Select all

PING www.google.com(mil04s25-in-x04.1e100.net (2a00:1450:4002:807::2004)) 56 data bytes
From 2001:b07:d448:f6b6:1eb0:44ff:feca:6ae3 (2001:b07:d448:f6b6:1eb0:44ff:feca:6ae3) icmp_seq=1 Destination unreachable: No route
From 2001:b07:d448:f6b6:1eb0:44ff:feca:6ae3 (2001:b07:d448:f6b6:1eb0:44ff:feca:6ae3) icmp_seq=2 Destination unreachable: No route
From 2001:b07:d448:f6b6:ba27:ebff:fe9e:b66a (2001:b07:d448:f6b6:ba27:ebff:fe9e:b66a) icmp_seq=9 Destination unreachable: Address unreachable
From 2001:b07:d448:f6b6:ba27:ebff:fe9e:b66a (2001:b07:d448:f6b6:ba27:ebff:fe9e:b66a) icmp_seq=10 Destination unreachable: Address unreachable

DirkS
Posts: 8851
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspberry pi doesn't connect to internet

Tue Aug 14, 2018 5:27 pm

Back to basics: restore interfaces and go back to dhcp.

1. unchanged /etc/network/interfaces

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
2. /etc/dhcpcd.conf: comment out the lines you added.
3. reboot and see what happens

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Tue Aug 14, 2018 7:08 pm

My /etc/network/interfaces

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
My /etc/dhcpcd.conf
#interface eth0
#static ip_address=192.168.1.138/24
#static routers=192.168.1.254
#static domain_name_servers=8.8.8.8
But there isn't connection

Code: Select all

 ping www.google.com
PING www.google.com(mrs08s05-in-x04.1e100.net (2a00:1450:4006:807::2004)) 56 data bytes
From 2001:b07:d498:efb6:1eb0:44ff:feca:6ae4 (2001:b07:d498:efb6:1eb0:44ff:feca:6ae4) icmp_seq=1 Destination unreachable: No route
From 2001:b07:d498:efb6:1eb0:44ff:feca:6ae4 (2001:b07:d498:efb6:1eb0:44ff:feca:6ae4) icmp_seq=2 Destination unreachable: No route
From 2001:b07:d498:efb6:1eb0:44ff:feca:6ae4 (2001:b07:d498:efb6:1eb0:44ff:feca:6ae4) icmp_seq=3 Destination unreachable: No route

DirkS
Posts: 8851
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspberry pi doesn't connect to internet

Tue Aug 14, 2018 9:54 pm

can you ping external ip addresses?

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 12:41 am

Code: Select all

 $ ping 216.58.205.100
PING 216.58.205.100 (216.58.205.100) 56(84) bytes of data.
64 bytes from 216.58.205.100: icmp_seq=1 ttl=53 time=23.1 ms
64 bytes from 216.58.205.100: icmp_seq=2 ttl=53 time=22.3 ms
64 bytes from 216.58.205.100: icmp_seq=3 ttl=53 time=21.3 ms
[email protected]:~ $

I don't understand. Why can't the pi resolves the ip address?

SurferTim
Posts: 1708
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 1:33 am

keiichi wrote: I don't understand. Why can't the pi resolves the ip address?
Bad dns server assignment? Looks like when you are using a domain name ping, it is using IPV6 addresses.

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 10:11 am

SurferTim wrote:
Wed Aug 15, 2018 1:33 am
Bad dns server assignment? Looks like when you are using a domain name ping, it is using IPV6 addresses.
Ok, but how can i resolve this problem? I need to set a static ip and appropriate dns

DirkS
Posts: 8851
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 10:15 am

keiichi wrote:
Wed Aug 15, 2018 10:11 am
I need to set a static ip
Why?

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 11:21 am

Because by my router isn't possible set a static ip and the router assigns a casual ip when a device connects to it.

SurferTim
Posts: 1708
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 11:24 am

This works for me. Edit /etc/dhcpcd.conf and add this at the end.

Code: Select all

interface eth0
static ip_address=192.168.1.138/24
static routers=192.168.1.254
static domain_name_servers=8.8.8.8
Do not modify /etc/network/interfaces unless you are using a bridge.

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 11:47 am

Ok. Remain the problem that the pi can't connect to internet with a letteral address

SurferTim
Posts: 1708
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 12:21 pm

If you have a PC connected to the localnet, check the DNS servers it is using. Google's DNS servers can be slow.

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 12:46 pm

I added the opendns. The result is same

Code: Select all

[email protected]:~ $ cat /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.1.138/24
static routers=192.168.1.254
static domain_name_servers=208.67.222.222 208.67.220.220 1.1.1.1 8.8.8.8 8.8.4.4
[email protected]:~ $

DirkS
Posts: 8851
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 1:01 pm

keiichi wrote:
Wed Aug 15, 2018 11:21 am
Because by my router isn't possible set a static ip and the router assigns a casual ip when a device connects to it.
Have you tried mDNS (Bonjour, zeroconf, avahi) you can then use hostname + .local (e.g. raspberrypi.local instead of an IP address.

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 1:24 pm

I don't know mDNS. I want understand because my raspberry pi do not resolve the internet address

SurferTim
Posts: 1708
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 1:30 pm

You might want to try nslookup and traceroute to determine the DNS problem. You might need to install network utilities to use them.

User avatar
DougieLawson
Posts: 33616
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 1:57 pm

What's in /etc/resolv.conf?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 2:54 pm

DougieLawson wrote:
Wed Aug 15, 2018 1:57 pm
What's in /etc/resolv.conf?

Code: Select all

 cat /etc/resolv.conf
# Generated by resolvconf
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4
SurferTim wrote:
Wed Aug 15, 2018 1:30 pm
You might want to try nslookup and traceroute to determine the DNS problem. You might need to install network utilities to use them.

Code: Select all

$ traceroute www.google.com
traceroute to www.google.com (216.58.205.100), 30 hops max, 60 byte packets
 1  192.168.1.254 (192.168.1.254)  1.681 ms  1.768 ms  1.977 ms
 2  10.5.131.74 (10.5.131.74)  10.872 ms  10.724 ms  10.822 ms
 3  10.250.136.6 (10.250.136.6)  10.810 ms 10.250.136.2 (10.250.136.2)  10.853 ms 10.250.136.6 (10.250.136.6)  10.726 ms
 4  10.251.5.194 (10.251.5.194)  10.870 ms  10.632 ms  12.376 ms
 5  10.254.11.245 (10.254.11.245)  15.392 ms  16.216 ms  15.511 ms
 6  10.254.20.245 (10.254.20.245)  18.446 ms  16.337 ms  16.168 ms
 7  89.97.200.201 (89.97.200.201)  16.713 ms  14.428 ms 89.97.200.197 (89.97.200.197)  13.846 ms
 8  93-63-100-209.ip27.fastwebnet.it (93.63.100.209)  22.176 ms  22.055 ms  21.937 ms
 9  93-63-100-10.ip27.fastwebnet.it (93.63.100.10)  21.816 ms 93-63-100-182.ip27.fastwebnet.it (93.63.100.182)  36.151 ms  22.036 ms
10  72.14.204.46 (72.14.204.46)  21.915 ms  21.799 ms  21.677 ms
11  108.170.245.65 (108.170.245.65)  24.860 ms 108.170.245.81 (108.170.245.81)  24.738 ms 108.170.245.65 (108.170.245.65)  26.256 ms
12  216.239.42.19 (216.239.42.19)  25.171 ms  24.911 ms 216.239.42.17 (216.239.42.17)  22.157 ms
13  mil04s26-in-f100.1e100.net (216.58.205.100)  21.874 ms  21.748 ms  22.248 ms

I have not nslookup

User avatar
DougieLawson
Posts: 33616
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 8:39 pm

sudo apt install dnsutils
gets you nslookup and dig.

Your /etc/resolv.conf looks OK as long as you can reach 208.67.222.222 you should be able to resolve a name to an IP address.

dig @208.67.222.222 www.bbc.co.uk

Code: Select all

[email protected]:~ $ dig @208.67.222.222 www.bbc.co.uk

; <<>> DiG 9.10.3-P4-Raspbian <<>> @208.67.222.222 www.bbc.co.uk
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9469
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.bbc.co.uk.                 IN      A

;; ANSWER SECTION:
www.bbc.co.uk.          277     IN      CNAME   www.bbc.net.uk.
www.bbc.net.uk.         277     IN      A       212.58.249.208
www.bbc.net.uk.         277     IN      A       212.58.244.66

;; Query time: 23 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Wed Aug 15 21:38:45 BST 2018
;; MSG SIZE  rcvd: 100

[email protected]:~ $
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 10:52 pm

Ok, I'm not undestanding.
I noticed who I can install program. The pi, now, is connected at internet but ping doesn't function.

Code: Select all

$ ping www.google.com
PING www.google.com(mil04s26-in-x04.1e100.net (2a00:1450:4002:808::2004)) 56 data bytes
From 2001:b07:d498:feb6:1eb0:44ff:feca:6ae4 (2001:b07:d498:feb6:1eb0:44ff:feca:6ae4) icmp_seq=1 Destination unreachable: No route
From 2001:b07:d498:feb6:1eb0:44ff:feca:6ae4 (2001:b07:d498:feb6:1eb0:44ff:feca:6ae4) icmp_seq=2 Destination unreachable: No route
Now, how do I konw what dns is used by the pi?

drgeoff
Posts: 8442
Joined: Wed Jan 25, 2012 6:39 pm

Re: Raspberry pi doesn't connect to internet

Wed Aug 15, 2018 11:26 pm

When you did the traceroute to www.google.com the DNS returned an IPv4 address.

When you try to ping www.google.com the DNS returns an IPv6 address. Why?

keiichi
Posts: 45
Joined: Mon Jul 27, 2015 8:33 pm

Re: Raspberry pi doesn't connect to internet

Thu Aug 16, 2018 12:06 am

drgeoff wrote:
Wed Aug 15, 2018 11:26 pm
When you did the traceroute to www.google.com the DNS returned an IPv4 address.

When you try to ping www.google.com the DNS returns an IPv6 address. Why?
Beautiful question!

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 6 guests