dyne / dowse

The Awareness Hub for the Internet of Things
http://dowse.eu
159 stars 17 forks source link

(Dowse Raspberry image) fix IP breaks functionality #42

Open christiansievers opened 6 years ago

christiansievers commented 6 years ago

Hi, the Raspberry image we got from you a couple of days ago works fine on my home network. I plug it in, the Dowse box gets an IP from the router, and then I turn off DHCP on the router. So far so good. I ask for a new DHCP lease on my laptop, and bingo, I'm in.

But when I edit /etc/network/interfaces on the Dowse box to give it a fix IP, that breaks things somehow. Dowse's DHCP doesn't work any more. I was stumped and even re-flashed the Raspberry to revert to the original image, but still the same problem.

I reverted things back to Dowse getting an IP from the router's DHCP, and now everything works again. So right now I can't restart the Dowse box, because that would leave it without an IP (it still uses the IP given to it by the router right now)...

For your reference, the home network is 192.168.178.0 The router is at 192.168.178.1 The dowse box gets this IP from the router: 192.168.178.20

This is the part in /etc/network/interfaces that breaks things, if I uncomment it (basically I was thinking to give it the same IP that it received from the router):

auto eth0

iface eth0 inet static

address 192.168.178.20

netmask 255.255.255.0

parazyd commented 6 years ago

On Sat, 30 Sep 2017, Christian Sievers wrote:

This is the part in /etc/network/interfaces that breaks things, if I uncomment it (basically I was thinking to give it the same IP that it received from the router):

auto eth0

iface eth0 inet static

                         address 192.168.178.20

                         netmask 255.255.255.0

You are also supposed to uncomment the two lines commented above. Also add gateway 192.168.178.1 (or whatever your gateway ip is (your router)), and optionally network 192.168.178.0.

christiansievers commented 6 years ago

Yes, I saw the two lines to uncomment, I had done that. And after DHCP didn't work I added exactly those lines you mention: 'gateway 192.168.178.1' 'network 192.168.178.0' Didn't help...

parazyd commented 6 years ago

This should most definitely work... Something wrong is happening. Can you paste your whole /etc/network/interfaces file?

Also what happens if you do /etc/init.d/networking restart on the Pi once it boots without an IP?

christiansievers commented 6 years ago

Hi, right now it's interfaces_dhcp.txt

What didn't work was this:

interfaces_fixed_ip.txt

Also what happens if you do /etc/init.d/networking restart on the Pi once it boots without an IP?

It's headless so if that happens I can only do a hard restart. I don't have a spare monitor at home, but I guess if it's important to try this I could use a serial cable to log in to the Pi.

By the way, not sure if this is related or not, there is another issue with the ON-button not working properly. I can click it and it reloads the page, but the button stays off, and that particular phone is left without connection. Is there a shell command I could try? Or any other idea? I also wouldn't mind turning on party mode, but my version of Dowse doesn't seem to give me that option, at least in the web interface. UPDATE: I ssh'd into the Dowse console and ran dowse-stop and then dowse-start, and now I can turn things on and off again

kneibdev commented 6 years ago

I have exactly the same problems. Tried for hours now but fixed IP doesn't seem to work. Also dhcp settings are ignored (see my other issue).

jaromil commented 6 years ago

Hi everyone! have you tried to edit /etc/dowse/settings (starting from the template in /etc/dowse/settings.dist)?

kneibdev commented 6 years ago

Yes I did... Status is now: After booting the Dowse Pi it has no default gateway. I have it set in /etc/network/interfaces After manually added it seems to work but Dowse is always dhcp-ing the range: 101 till 149, whatever I set in /etc/dowse/settings

jaromil commented 6 years ago

ACK, you are right (well, its 101-249, anyway yes) the dhcp range setting isn't converted into the configuration of the ISC DHCP daemon.

About the gateway, you mean also setting wan inside /etc/dowse/settings doesn't give a default gateway on boot? In this case we may want to fix this as well, however is good practice to use also /etc/network/interfaces

kneibdev commented 6 years ago

Correct: wan=192.168.100.102 is set in my /etc/dowse/settings but after booting I don't have a default gw. Have to add it manually.

Can i specify the range for DHCP for the time being somewhere else? Tried als in ~dowse/dowse-src/daemons/dhcpd but no luck.

jaromil commented 6 years ago

I'm fixing that (dhcp range) right now and will do more tests on the wan.

the problem is generated by a transition to a smarter detection system, but indeed manual settings should always override all correctly.

To receive the fixes you need to use latest git master branch.

kneibdev commented 6 years ago

Okay thanks. Noob question: can I get to latest git master when I started with the downloadable sdcard image?

jaromil commented 6 years ago

Its actually a good question that we should include in the documentation.

I will try to sketch the procedure, but may be missing some detail:

kneibdev commented 6 years ago

This results in an error:

devuan% more dhcpd.conf                                                                                                        Dowse
option routers 192.168.100.101;
option domain-name "dowse.it";
option domain-name-servers 192.168.100.101;
authoritative;
db-time-format local;
ddns-domainname "dowse.it";
local-address 192.168.100.101;
omapi-port 7911;

subnet 192.168.100.0/24 netmask 255.255.255.0 {
  range 192.168.100.10 192.168.100.65;

  on commit {
    set clip = binary-to-ascii(10, 8, ".", leased-address);
    set clhw  = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    execute("/usr/local/dowse/bin/pendulum", "lease", clip, clhw, host-decl-name);
  }
}
devuan%

the /24 shouldn't be in the subnet I think...

  .  starting daemon: dhcpd
Internet Systems Consortium DHCP Server 4.3.4
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
/home/dowse/.dowse/run/dhcpd.conf line 10: Expecting netmask
subnet 192.168.100.0/
                     ^
Configuration file errors encountered -- exiting
stucksubstitute commented 6 years ago

Hi!

have you tried to edit /etc/dowse/settings (starting from the template in /etc/dowse/settings.dist)?

The instructions in that file aren't very clear. So the actual, live settings file should be /etc/dowse/settings, not /etc/dowse/settings.dist ? Can you clarify please?

kneibdev commented 6 years ago

Yes I do my settings in /etc/dowse/settings but @jaromil changed some code to use the dhcp range. But there's still an error.

What file generates: /home/dowse/.dowse/run/dhcpd.conf ??

kneibdev commented 6 years ago

@jaromil would you mind to have a look at this dhcpd.conf error that occurs in latest branch? Thanks

jaromil commented 6 years ago

sure. sorry this is occurring also because our regression tests on travis are currently broken

kneibdev commented 6 years ago

Is there any view on a solution for this? Thx..

jaromil commented 6 years ago

its rather simple. we will merge our webui2 branch which has a lot of updates and then also fix this glitch, probably this week already.

kneibdev commented 6 years ago

Okay, will wait for that...

jaromil commented 6 years ago

its fixed in my test environment now (current master branch). how about your setup?

kneibdev commented 6 years ago

Nope, the errormessage mentioned before is gone but the dhcp daemon doesn't give a default-gw to the clients.

root@devuan:/home/dowse/.dowse/run# more dhcpd.conf
option routers 192.168.100.101;
option domain-name "dowse.it";
option domain-name-servers 192.168.100.101;
authoritative;
db-time-format local;
ddns-domainname "dowse.it";
local-address 192.168.100.101;
omapi-port 7911;

subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.10 192.168.100.65;

  on commit {
    set clip = binary-to-ascii(10, 8, ".", leased-address);
    set clhw  = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    execute("/usr/local/dowse/bin/pendulum", "lease", clip, clhw, host-decl-name);
  }
}
jaromil commented 6 years ago

AFAIK the line option routers IP; should be it: that's the ISC DHCP configuration option to set the announced default gateway. Are you sure there is no other DHCP on your local test network?

kneibdev commented 6 years ago

Yes, sorry, you are right.

But still this part of the config:

#########################
# SAFE TO LEAVE UNCHANGED
# in most cases, if you don't know what you are doing
# its better to not change the values below.

# under which system UID and GID dowse will run
# default is current user
# dowse_uid=proxy
# dowse_gid=proxy

# what network range we choose for our LAN (class C)
dowse_net=192.168.100.0/24

# which netmask to be applied (default is class C)
netmask=255.255.255.0

# ip range reserved for guests (first,last,leasetime)
dowse_guests=192.168.100.65,192.168.100.70,48h

Results in this file ~dowse/.dowse/run/dhpcd.conf:

root@devuan:~# more /home/dowse/.dowse/run/dhcpd.
more: stat of /home/dowse/.dowse/run/dhcpd. failed: No such file or directory
root@devuan:~# more /home/dowse/.dowse/run/dhcpd.conf
option routers 192.168.100.101;
option domain-name "dowse.it";
option domain-name-servers 192.168.100.101;
authoritative;
db-time-format local;
ddns-domainname "dowse.it";
local-address 192.168.100.101;
omapi-port 7911;

subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.10 192.168.100.65;

  on commit {
    set clip = binary-to-ascii(10, 8, ".", leased-address);
    set clhw  = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    execute("/usr/local/dowse/bin/pendulum", "lease", clip, clhw, host-decl-name);
  }
}

I expected the range to be .65 - .70

jaromil commented 6 years ago

ok yes the config is not reflecting all the settings, thanks

kneibdev commented 6 years ago

Ah ok, I think I am almost there... last problem is that DNS on dowse on all clients is returning it's own ip. (ip of dowse box = 192.168.100.101, cable modem/router = 192.168.100.102)

So on a client every nslookup returns in ip of dowse box: On dowse:

devuan% nslookup nu.nl                                                                                                               Dowse
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   nu.nl
Address: 174.129.25.170

devuan%           
                                                                                                              Dowse

On client with dhcp address from Dowse :


devuan% nslookup nu.nl                                                                                                               Dowse
Server:     192.168.100.101
Address:    192.168.100.101#53

Non-authoritative answer:
Name:   nu.nl
Address: 192.168.100.101

devuan%                                                                                                                              Dowse
jaromil commented 6 years ago

this is normal, because Dowse tunnels the DNS via dnscrypt-proxy and because your client is not yet "authorised" to browse. To become admin visit http://dowse.it from inside (or directly 192.168.100.101) and with latest git master you will see the web interface where you can become admin and start watching and authorising devices.

kneibdev commented 6 years ago

no that doesn't work. Looks like there no webserver running. Nothing listening on port 80.

But many many thanks for you effort and help so far!! 👍 I think best for me is to come back in a few weeks/months.

UPDATE: webui2 is never started. No error message...have no idea why.

jaromil commented 6 years ago

Thanks to you too for helping us to understand how to smooth all edges. I'm taking notes so we address them in the next code sprint. I think the webui2 may not be started automatically if you don't recompile and make install the latest, then you need to login as user dowse pass dowse and then do start webui2. It should start with the latest version of the software on git branch master, however we'll just release a new SD card image soon.

kneibdev commented 6 years ago

I just did: remove ~dowse/dowse-src and started all over by git clone...etc And then all steps, make and as root make install. Then (with my original /etc/dowse/settings) dowse starts ok, with good dhcpd.conf (origin of this topic) but webui2 doesn't run. When doing start webui2 as user dowse:

devuan% start webui2                                                                                                             Dowse
  .  generating configuration for webui2
  .  starting daemon: webui2
devuan%

but noting listening on port 80

devuan% ps -ef|grep webui                                                                                                        Dowse
dowse    12250 10504  0 22:26 pts/0    00:00:00 grep webui
devuan%
devuan% netstat --listen                                                                                                         Dowse
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 devuan:6378             *:*                     LISTEN
tcp        0      0 devuan:6379             *:*                     LISTEN
tcp        0      0 *:29999                 *:*                     LISTEN
tcp        0      0 192.168.100.101:domain  *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 *:1883                  *:*                     LISTEN
tcp        0      0 *:1888                  *:*                     LISTEN
tcp        0      0 *:7911                  *:*                     LISTEN
tcp6       0      0 [::]:29999              [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
tcp6       0      0 [::]:1883               [::]:*                  LISTEN
udp        0      0 *:49188                 *:*
udp        0      0 192.168.100.101:domain  *:*
udp        0      0 192.168.100.101:bootps  *:*
udp6       0      0 [::]:44016              [::]:*
raw        0      0 *:icmp                  *:*                     7
raw        0      0 *:255                   *:*                     7
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     SEQPACKET  LISTENING     1193     /run/udev/control
devuan%

but noting in the logfiles...

Thank you again for your help!