As others have said, this sound like a DNS problem, maybe caused by router mis-configuration.
The way I investigate these kind of issues is:
1. Ping you own router in terminal: e.g. ping 192.168.0.1
2. Ping a server on the intranet
by IP: e.g. ping 172.217.20.46
3. Ping the same server b
y URL: ping google.com
With a DNS problem, 1 and 2 works, 3 fails. If instead it is a routing problem 1 works and 2 and 3 fails.
Check DNS by using the command dig: dig google.com, you get something like this back:
; <<>> DiG 9.10.6 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64822
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 5 IN A 172.217.20.46
;; Query time: 138 msec
;; SERVER: 10.0.1.10#53(10.0.1.10)
;; WHEN: Tue Nov 19 13:21:28 CET 2019
;; MSG SIZE rcvd: 55
The SERVER line, says which DNS server responded, and the ANSWER SECTION gives the translation of the URL to the IP address you got from the server. In your case you are probably not getting a response, possibly because the name server is not correctly configured.
If you go to Settings > Network > Advanced > DNS you can see or change the DNS settings. The simplest solution can be to set it to 8.8.8.8 for the Google DNS server.
Otherwise the principle is that router sets it when you get a WiFi lease. The router can get the information from upstream, i.e. your ISP. But it can also be set explicitly in the router. Possible you have changed these setting at some point, to some server which is no longer working.
Some things to consider:
- You can configure more than one name server, I generally use two
- DNS entries are cached, possible leading to some (cached) websites working, others not
- Beware of any change of network settings you do, as they persists, generally information should come from up stream, it is easy to forget that you have configured something locally