0

I'm trying to setup a static IP address on my WIFI that can access Internet.

this my file /etc/dhcpcd.conf

interface wlan0

static ip_address=192.168.1.200/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

This is my file resolv.conf

nameserver 192.168.1.1

This is the result of my command, route -ne

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0

I can connect through SSH to my pi, once the IP address has been changed.

However, when doing a sudo ping google.com, this is what I have

ping: unknown host google.com

When I ping 8.8.8.8 I get

(8.8.8.8) 56(84) bytes of data. From 192.168.1.200 icmp_seq=1 Destination Host Unreachable

When I leave it set to DHCP then everything works.

Any ideas on what am I missing?

Cheers

Ingo
  • 42,961
  • 20
  • 87
  • 207
Andy K
  • 123
  • 8

1 Answers1

2

First setup your Raspberry Pi to use default DHCP and check if everything works. Then notice the output from this commands:

rpi ~$ ping -c3 192.168.1.200
rpi ~$ ip -4 route
rpi ~$ cat /etc/resolv.conf

If you got a response from the ping of course you cannot use that ip address again. But even you don't got a response you are not on the save side that it will not be used later. For static ip_address use an ip address that will not be served by your DHCP server, most likely your router. Look at your router configuration what address range it use to serve ip addresses. Select an ip address that is not in this range but in the subnet of your local network.

For static routers use the ip address you got with ip -4 route. Use the ip address from the line default via ....

For static domain_name_servers use the ip address you got with cat /etc/resolv.conf. If in daubt use static domain_name_servers=8.8.8.8.

Never touch /etc/resolv.conf! It is mangaged by openresolv and may be overwritten.

It would help us you can tell if there are other devices on your network and if they can get into the internet, e.g. a PC or a MAC and what gateway and dns server it has configured. Also knowing the address range reserved for DHCP is very helpful.

Ingo
  • 42,961
  • 20
  • 87
  • 207