Forum OpenACS Q&A: how does ns_info work

Collapse
Posted by Pavel Boghita on
Reading through aolserver docs, I was able to learn what ns_info does, but not how it does it.

For now this is what my "homework" on this subject looks like: my best guess so far was that for hostname and address it goes to /etc/hosts. I have tried to modify localdomain (in etc/hosts) to something like lokaldomein expecting for [ns_info hostname] to come up with the modified entry. It retrieved localhost.localdomain as it was before modification, but [ns_info address] returned nothing. So I am not so sure about hosts anymore
Taking advice from a previous post , I used this script, to check what ns_info was returning:

ns_return 200 text/plain "hostname: [ns_info hostname]
address: [ns_info address]
file: [ns_info config]

David Walker suggested a script for setting address in nsd.tcl to the ppp0 (eth0 in his case) address. I modified so it worked with my setup. This is the relevant section of my nsd.tcl file:

# the script takes the ip address from ppp0 and returns it as the variable address

set hostname bradut.com
set varawk {{print $2}}
set varsed {-e s/.*://}
set address [exec /sbin/ifconfig ppp0 | grep addr | awk $varawk | sed $varsed]

In this way, every time my ip changes nsd.tcl automatically changes its setting; ddclient also takes care of the dns records on dyndns server, so my hosting setup via adsl with dynamic ip seems to be ok.
However, I am not sure wether what I've done is the most elegant way of solving this problem of changing ip. So I would like to know whether there is a way to specify in whatever conf file ns_info uses to get its hostname and address from, that the ip address for my server is the ppp0 address and the hostname is myhostname.

Thank you all very much for all your help so far.

Collapse
Posted by Jade Rubick on
I'm not sure what you have to restart to get the /etc/hosts file re-
read, but did you either restart the comupter, or restart the
network connections... just modifying the /etc/hosts file probably
won't do it..
Collapse
Posted by Pavel Boghita on
I have restarted the computer and I am sure the /etc/hosts was
re-read... but still nothing changed in the ns_info result.
Collapse
4: "mistery" solved... (response to 1)
Posted by Pavel Boghita on
just trivial facts for some, but I thought I'll write my conclusions anyway... as suggested in a previous post a while ago.
ns_info hostname goes to /etc/sysconfig/network (which contains information like hostname and domain name), then it takes this newly found hostname and gets its corresponding ip address from /etc/hosts