Author Topic: Programming Task: make dcerouter name automatically resolvable.  (Read 2063 times)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5498
  • DOES work for LinuxMCE.
    • View Profile
Hello everyone.

We currently keep the name of the system inside the web admin's network configuration panel.

It is, by default, set to DCERouter, and we need for it to be resolvable by name on every machine on the network, so somebody can go to a windows, mac, or linux machine and type

http://dcerouter/

into a browser, and have it just work.

Any takers?

-Thom

mhorst

  • Veteran
  • ***
  • Posts: 72
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #1 on: May 14, 2010, 06:24:09 pm »
I'll take a look, but the amount time I have is erratic, so if somebody else is interested too; go right ahead (you can probably use what I have so far as a starting point).

By the way, if possible I would like to expand this feature so that we can associate names with MAC addresses or something, such that the names of devices can also be used to resolve them.

Anyhow, I saw that LinuxMCE already includes a DNS server (bind9), so I read some HOWTOs and played with the config files a bit.
I added two zones to /etc/bind/named.conf.local:
Code: [Select]
//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "linuxmce.lan" IN {
type master;
file "zone.linuxmce.lan";
};

zone "80.168.192.in-addr.arpa" {
type master;
file "revp.linuxmce.lan";
};

I also added the files /var/cache/bind/zone.linuxmce.lan:
Code: [Select]
;
; dns zone for linuxmce. lan
;
$ORIGIN linuxmce.lan.
$TTL 1D
@ IN SOA dcerouter hostmaster (
2009051401      ; serial (YYYMMDD of last change, followed by a sequence number)
8H ; refresh
4H ; retry
4W ; expire
1D ) ; minimum
NS dcerouter
; DCE router address
dcerouter A 192.168.80.1
; Addresses of other devices
moon54 A 192.168.80.2

and I added the file /var/cache/bind/revp.linuxmce.lan:
Code: [Select]
;
; dns zone for linuxmce. lan
;
$ORIGIN linuxmce.lan.
$TTL 1D
@ IN SOA dcerouter hostmaster (
2009051401 ; serial (YYYMMDD of last change, followed by a sequence number)
8H ; refresh
4H ; retry
4W ; expire
1D ) ; minimum
NS dcerouter
; DCE router address
1 PTR dcerouter
; Addresses of other devices
2 PTR moon54

I can now resolve dcerouter.linuxmce.lan and moon54.linuxmce.lan from my laptop and it will direct me to the correct IP address.
To be able to remove the ".linuxmce.lan", I think I have to reconfigure the DHCP server on the core to provide the "linuxmce.lan" domain name to its clients. I haven't gotten around to trying that yet.
And, of course, if this all works the new files I created in /var/cache/bind will have to be updated automatically rather than manually.

Also, it seems that the core itself considers itself to be in the domain provided by my ISP, and uses the DNS server of my ISP directly. So currently the only place in the network where I cannot resolve the new names is from the core itself. (Of course the core has a hosts file, so that doesn't really matter, but I would like to have the name resolution work the same on every system in the network.)

So that's my progress so far.

posde

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2984
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #2 on: May 14, 2010, 08:35:32 pm »
mhorst,

very nice.

Look at the dhcp template files, and try to setup something similar for the zone files.

sambuca

  • Guru
  • ****
  • Posts: 446
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #3 on: May 14, 2010, 10:15:18 pm »
And remeber to avoid hard-coding anything. If the host name is configurable in the web admin, load it from the web admin.

best regards,
sambuca

mhorst

  • Veteran
  • ***
  • Posts: 72
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #4 on: May 15, 2010, 11:48:50 pm »
Thanks.

I checked what happens if I set 
Code: [Select]
option domain-name "linuxmce.lan"; in the /etc/dhcp3/dhcpd.conf file.
After that I can actually resolve http://dcerouter on my laptop, so that looks good.
I now know what changes should make to the config files, now it is a matter of getting the LinuxMCE code to do that.

I saw that the domain name is also configurable in the web-admin, so I figured it would be a good first step to add the domain name to the DHCP template file, and after that create a template for the bind files.

The dhcp template contains several keys like %CORE_INTERNAL_ADDRESS%, so I wanted to check where this template is filled in and see if there is already a key for the domain name. If that would be the case the DHCP changes would be a simple matter of updating the template.
However, it seems that the template is not used; my search lead me to PlutoDHCP.cpp file in the source code, and that source code contains a function that produces the text for the dhcpd.conf file from scratch. The output of this function seems to be the same as the template (except for the comments on the first 3 lines), but it does not actually use the template at all.

I guess that means I should not alter the template but just the PlutoDHCP.cpp file, or am I missing something?

Anyway, is there an example of how the template files should be used? I saw that the ddclient.conf.template is filled in the DynamicDNS.sh script. I can create a similar approach for the bind9 config files (shell scripts that use the ReplaceVars function), if that is the proper way to go.

mhorst

  • Veteran
  • ***
  • Posts: 72
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #5 on: June 05, 2010, 11:44:19 am »
Ok I got a bit futher. I modified PlutoDHCP. It now automatically includes the domain name from the web-admin's network settings pageinto the dhcpd.conf file. I attached the svn diff with my changes to this post, for anybody who's interested.

I found some issues when I tried following the instructions on http://wiki.linuxmce.org/index.php/Building_LinuxMCE_0810. The avenard repro key was not installed by one of the scripts, resulting in an error, and the build did not complete succesfully.
I was able to work around that because the PlutoDHCP component which I needed to change did build.

I also have some questions:
1) I made my changes on the "LinuxMCE-810" branch, because that is the branch that I got after following the instructions on the wiki page. Is this correct? I actually expected to be working on the "trunk" branch instead.
2) What's with the following lines in the diff?
Code: [Select]
-#define  VERSION "<=version=>"
+#define  VERSION "2.0.0.44.10052422980"
I never changed that line, and I guess the version is supposed to be filled in automatically. Should I manually remove them before a commit or is this done automatically?
3) How can I ensure that new files will be included in an existing package? For the bind config files I will create a new template file, and that will have to be included in the pluto-boot-scripts package once its finished. There's probably a config file somewhere, but I haven't found it yet.
4) Is there a way to build an individual package? For the PlutoDHCP I just manually installed the binary, and since it is already part of a package I am quite sure that it will be included and installed as normal. I am not so sure about a new file that is added to a package however, so I'd like to test no. 3), but I would like to do that by building the individual package.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5498
  • DOES work for LinuxMCE.
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #6 on: June 05, 2010, 06:01:28 pm »
the original <=version=> line should be put back into place, as this is replaced by the Builder when it makes its passes.

This can be avoided by applying the changes to a clean source checkout, completely outside of the purvey of the builder.

Thanks so much for your patch! :)

Could you put this in a trac ticket, @ http://svn.linuxmce.org/ so we can keep track of it? :)

-Thom

mhorst

  • Veteran
  • ***
  • Posts: 72
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #7 on: June 06, 2010, 12:43:12 pm »
Ok, I'll make a trac ticket as soon as I've got a patch on a clean checkout.

Question though: should that checkout be on the trunk or on the LinuxMCE-810 branch?

Also, I always like to check whether my code at least builds before sending it out. So, is there a way to build with my patch, without the builder replacing the #DEFINE version ?
I quickly tried doing a make on a clean checkout (without my patch), but I get a message that ../include/version.h does not exist. (Which is correct, there is a version.h.prep file though...)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5498
  • DOES work for LinuxMCE.
    • View Profile
Re: Programming Task: make dcerouter name automatically resolvable.
« Reply #8 on: June 06, 2010, 06:48:56 pm »
Yes, build on the 0810 branch.

You can also build some modules in the src/ tree by defining SNR_CPPFLAGS and SNR_LDFLAGS before compiling. They just have to be defined, doesn't have to be anything in them.. I just put a space in them.

-Thom