0

I recently changed ISPs. I got a new router. After a lot of messing about I have the router running almost the way I want it. However, since then my Raspberry Pi can't resolve external addresses. So, doing stuff like ping www.google.com the name doesn't resolve. I get the following message:

ping: www.google.com: Temporary failure in name resolution

The interfaces in /etc/network has this:

auto lo

iface lo inet loopback

iface eth0 inet static
address 192.168.0.42
gateway 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

resolv.conf contains this:

domain Home
search Home
nameserver 192.168.0.1

When I do dig google.com @192.168.0.1 I get

; <<>> DiG 9.10.3-P4-Raspbian <<>> google.com @192.168.0.1 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42497 
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: 
;google.com. IN A 

;; ANSWER SECTION: 
google.com. 289 IN A 216.58.198.110

;; Query time: 17 msec 
;; SERVER: 192.168.0.1#53(192.168.0.1) 
;; WHEN: Tue Nov 20 10:36:14 GMT 2018 
;; MSG SIZE rcvd: 44
  • 1
    Can you edit your question and post the contents of /etc/resolv.conf? – Mr Shunz Nov 16 '18 at 10:18
  • is the py connected via physical ether-net cable to the router? – ctrl-alt-delor Nov 16 '18 at 11:05
  • It uses ethernet, not wifi. – snert Nov 17 '18 at 15:11
  • Edited to show resolv.conf. I have to say I hadn't thought of that but the IP address in there for the nameserver is the IP address of the router. Personally I would have thought the router acts as a DNS for the network wouldn't it? – snert Nov 17 '18 at 15:15
  • What do you get if you do dig google.com @192.168.0.1 and dig google.com @8.8.8.8? – ctrl-alt-delor Nov 18 '18 at 14:33
0

It looks like you have set the Py's IP address as a static address. This is probably not what you want.

Most modern networks use DHCP. There will be a DHCP server built into the router/ethernet-switch/modem combo that your ISP provided.

You need to set the mode of the interface to auto.

On my py the file /etc/network/interfaces contains only

# 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

and /etc/network/interfaces.d/ is empty directory.

  • Yes, I do want a static IP. That is why it is configured that way. The static IP range on the router is between 2 and 127. Anything from 128 upwards is the DHCP range. The pi sits on 42 because I need to connect to it from outside using port forwarding, so I give it a static IP – snert Nov 17 '18 at 15:10
  • So this may not be the problem, but it can lead to problems. Does your DHCP server have option to statically assign IP addresses. Static-dhcp gives the advantage of static, but better manageability (the DHCP server has to be statically assigned). – ctrl-alt-delor Nov 18 '18 at 14:35
  • Yes. As I said, the outer is configured to provide 192.168.0.1 - 127 as static IP range and 128 and up are DHCP. – snert Nov 20 '18 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.