0

This is weird but I followed the steps to setup static IP using DHCP.

My dhcpcd.conf file:

interface wlan0
static ip_address=192.168.0.100/24
static routers=191.168.0.1
static domain_name_servers=8.8.8.8

Rebooted and i could access google, search on it but a few websites are not able to open for some reason. For example, i could open facebook. But not github or stackexchange. No idea why. When wlan0 DHCP automatic, all websites able to open fine.

Anybody knows why and how to solve it?


EDIT: Thanks for responding to my question. So here is what I tried:

Based on answer shared https://raspberrypi.stackexchange.com/a/74428/133085 - using "request 192.168.0.100" in dhcpcd.conf, it resulted in Auto DHCP instead. that means my router is rejecting this IP for some reason.

The thing is, I COULD set a static IP address of 192.168.0.110 (or any other number) on my Mac. So I know my router do accept static IP settings. Just on my rasp pi seems to be having this issue.

Also just to add the error I get from browser is:

This site can’t be reachedhttps://raspberrypi.stackexchange.com/ is unreachable.
ERR_ADDRESS_UNREACHABLE
GeneCode
  • 111
  • 5
  • What errors do you get? It is always worth using two DNS servers just in case one does not respond in time. https://developers.google.com/speed/public-dns/ Recommends 8.8.8.8 AND 8.8.4.4 for IPv4 though I normally mix DNS suppliers and use 1.1.1.1 and 8.8.8.8 if I'm ok with being tracked and get ads. –  Apr 24 '21 at 14:50

2 Answers2

1

I found a workaround. The DHCP method doesn't work for me. I mean it did change the IP of rasp pi, and I am able to detect rasp pi on the wifi network using IP scanner, but.... the rasp pi itself fails to open some website (including this site). It can open google.com only.

So, what i did was added a ifconfig cmd line in the last line of .bashrc in /home/pi.

ifconfig wlan0 192.168.0.100

And it works. I still am interested if anybody got it working fully with DHCP method. So pls post your answer if there is one.

GeneCode
  • 111
  • 5
0

The most probable reason it works with DHCP in that this would be using the DNS provided by the ISP. Attempts to bypass this are not guaranteed to work as many jurisdictions require ISP to filter IP.

I suggest that rather than trying to set a static IP Address you request the DHCP server to assign a predictable IP Address. See https://raspberrypi.stackexchange.com/a/121830/8697

If for some reason you do want a static IP Address see How to set up Static IP Address which explains how to do it correctly.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • Not working. I edited my question to add more details after following your advice. – GeneCode Apr 25 '21 at 04:15
  • @GeneCode The most likely reason for rejection is because 192.168.0.100 is not **within the range managed by the DHCP server** . Only you can determine this by looking at your router settings. Many routers only allocate within a limited range. Routers DO NOT "accept static IP settings" - the router is NEVER consulted! If you want to involve the router you should use the `inform` directive. – Milliways Apr 25 '21 at 06:16