Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Static IP Address #71

Closed
xoseperez opened this issue Feb 13, 2017 · 13 comments
Closed

Using Static IP Address #71

xoseperez opened this issue Feb 13, 2017 · 13 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: J.D. (Bitbucket: Harry_Reutter, GitHub: Unknown)


Hi,
i am not able to use a static IP Address..i entered everything , but after each reboot the webserver comes up with the DHCP Address assigned from my router..

The settings are still in the WiFi configuration, they just are not being used.

Best regards,
Harry

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Hi Harry

Yeah I can confirm the behaviour on 1.6.4, static is ignored if your dhcp server responds fast enough, this was with 1 Wifi network configure Not sure if I saw this on 1.6.0.

Later Ferdie

@xoseperez
Copy link
Owner Author

1.6.4? You are in the future!
Anyway... that's weird. There is a known issue with the ESP8266 that it does not honour static IP when in autoconnect mode. But the firmware should be disabling autoconnect when using static IP to prevent that issue on reboot and force the code to go through the "manual" connect procedure. I have just tested it on a D1 and a Sonoff TH using this procedure:

  1. Boot the device and open a terminal window
  2. Connect to the IP of the device as stated in the debug log (enter password...)
  3. Configure a static IP in the web interface (ip, gw, mask and dns). Use only one network to ensure it is the one it will use.
  4. Click the reconnect button, check in the terminal the device disconnects and reconnect using the new IP
  5. Check the autoconnect mode (type read WIFI) and check it is set to 0
  6. Reset the device (for the web interface or type reset in the terminal)
  7. The device reboots and connects again using the static IP.
  8. Check autoconnect again, it is still set to 0

Can any of you reproduce these steps?

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


lol .. my bad too many number in one place - my head, yes 1.6.2

Sure let me go find find the basic and fire it up.

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Done step 3 ... no issues - get the pop-up that config saved.
4 Click - do you want to reconnect - yes
5 - here is the issue

#!arduino

Mode: STA
PHY mode: N
Channel: 12
AP id: 0
Status: 5
Auto connect: 1

Confirmed after reconnect to old dhcp IP that configuration was saved - new incognito with re-auth on web interface.

reset from terminal

#!arduino


[WIFI] MODE STA -------------------------------------
[WIFI] SSID IoT
[WIFI] IP   192.168.1.dhcp    so it says at what DHCP sets. 

read WIFI

#!arduino

Mode: STA
PHY mode: N
Channel: 12
AP id: 0
Status: 5
Auto connect: 1

Static config is being ignored on Basic Sonoff.

Later Ferdie

BTW

#!arduino

get IP0 

returns the static IP that I set .. so that is save to device.

same for dns gw mask ... all saved correctly

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


OK found the bug ...

You must not use the DNS server 8.8.8.8 you have to change that. Yes google's DNS server is reachable from my network. But changing it to my local DNS forward cause the device to

#!arduino

Mode: STA
PHY mode: N
Channel: 12
AP id: 0
Status: 5
Auto connect: 0

and on reset / reconnect I now get the correct static IP address.

This is only true for the initial web config ... after the initial Auto connect is set it stays at 0 even if you manually in the web interface change it back to 8.8.8.8

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Did even more testing ... - actually like the terminal never used it till now.

Using DNS 8.8.8.8 as the initial config is only an issue when you first configure the static IP via the web interface. Setting it to anything other than the 8.8.8.8 seems cause auto connect to be set to 0 and then the static works as expected. You can change it back to 8.8.8.8 and static is still configured but now with 8.8.8.8 as the DNS server.

Setting the configuration via the terminal does not show the same issue.

If you remove all the network settings - reset you will see the device boot into AP mode.

#!arduino

set ssid0 xxx
set pass0 xxx
reconnect 
set ip0 x.x.x.x
set gw0 x.x.x.x
set mask0 x.x.x.x
set dns0 8.8.8.8

and you reconnect you all good on static.

Later Ferdie

@xoseperez
Copy link
Owner Author

OK, is it possible that you are not actually typing the DNS in the web interface? I mean, the "8.8.8.8" is a place holder, not an actual value.
And if you don't type all four values (ip, gw, netmask and dns) the static IP configuration does not work...

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


I think you are correct .. I was at some point leaving the DNS as the default "value" since it looks like it is captured even if it is greyed out. 8.8.8.8 is an actual google DNS server so it does not look like a place holder nor does the netmask 255.255.255.0 but for some reason I tend to retype that.

Ok so leaving the default values and not setting DNS and MASK if the real issue, from a UI view both can be seen as configured but clearly from the terminal it was not. So doing a reconnect or reset would mean that because you do not have all the information the device goes and gets dhcp information.

Maybe an improvement of sorts to make it clear that the info for mask and DNS should be replaced? Of a check that detect that if an static IP is typed clear the "default" values from the UI to indicate that it needs to be captured?

Later Ferdie

@xoseperez
Copy link
Owner Author

Original comment by J.D. (Bitbucket: Harry_Reutter, GitHub: Unknown):


Hi,

you are right, this solved it for me..although the DNS wasn't the problem, the subnet mask was the issue..it looked like it was pre-occupied, but it was just a placeholder..so that was my bad i guess :)

Thanks
Harry

@xoseperez
Copy link
Owner Author

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Yeah - had a look at my two POW's that I saw the issue on first ... here I did assume - my bad, that the default mask and dns was not needed to be set when configuring the static IP - since workable values are being displayed.

Overwrote both mask and dns and static is working as expected.

Later Ferdie

@xoseperez
Copy link
Owner Author

OK
I think the best option would be to set them to default values if not populated.
So if the user enters the IP and GW but not the DNS or NETMASK they will be set to 8.8.8.8 and 255.255.255.0 by default.

@xoseperez
Copy link
Owner Author

Fixed in 1.6.3

@xoseperez
Copy link
Owner Author

Removing milestone: 1.7.0 (automated comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant